Build error: COMReference .NET CORE 3.0: AxImp not found - .net-core

I am trying to compile a .NET CORE 3.0 application that has a COM reference. Unfortunately when trying to build that application that has the reference, I am getting a build error:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2726,5):
error MSB3091:
Task failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed.
The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the
InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools-x86.
You may be able to solve the problem by doing one of the following:
1) Install the Microsoft Windows SDK.
2) Install Visual Studio 2010.
3) Manually set the above registry key to the correct location.
4) Pass the correct location into the "ToolPath" parameter of the task.
I understand that something is probably wrong with the setup or configuration (?), but cannot figure out what exactly. I have Visual Studio 2019 installed (the latest one at the moment of writing, 16.3.9). The application is set to target .NET CORE 3.0, that should support <ComReference ...> element.
How do I build an application that has a COM REFERENCE with .NET CORE 3.0 using Visual Studio 2019? I am building from VS2019 IDE. As of my understanding, it should not even look for the "AxImp", it should probably look for the "TlbImp". Also, why is it looking for Visual Studio 2010?? Windows SDK is installed. Does it need some specific version? Which one?
I tried to remove and then add the reference again using project references, nothing changed. Am I missing something?

After installing .NET SDK 4.7.2 the problem is gone. I had 4.8 version before (installed by default with VS 2019)

Related

ASP.Net Core WebApi Project creates an empty solution

I am trying to create a ASP.Net Core WebAPI application, i installed every sdk and runtime i was told to.
I then go into Visual Studio and create the Project from the ProjectCreator.
What I end up with is an empty solution and a project in the specified directory that i cannot open, with the error message the Project cannot be opened because it couldnt find a fitting sdk
(btw, creating it with .netCore3.1)
Heres a list of my installed sdks/runtimes:
.NET Core Runtime 2.1
.NET Core Runtime 3.1
.NET Core SDK 3.1.1
.NET Core SDK 3.1.4
.NET Runtime 5.0
.NET SDK 5.0.2
.NET SDK 5.0.3
ASP.NET Core 3.1.17
ASP.NET Core 5.0.8
This is what my solution explorer looks like tho the csproj is correctly placed
Whats seems to be the problem? Too many runtimes/sdk?
Are they overriding each other? Visual Studio cannot choose? I am baffled, this should work :/
[Edit1]
This is the guide I am following: https://learn.microsoft.com/de-de/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio
[Edit2]
I found a command that lets you see every sdk and runtime the dotnet/cli can access/see
(dotnet --info)
Looks like dotnet doesnt seem to find an sdk i installed
[Edit3]
I tried to manually install the .net core SDK 3.1 binaries into the C:\ProgramFiles\dotnet folder, but to no avail, dotnet --info still doesnt recognize the SDK
[Edit4]
I got it working, I will post the solution as an answer.
Heres what I did:
I uninstalled my Visual Studio IDE with the Visual Studio Installer
I uninstalled every .NET (Core) SDK and .NET (Core) Runtime
I did a fresh Visual Studio install with only the components i really need
After that I checked the dotnet --info command and there was it, 2 SDKs were installed. When I create the WebAPI Project now, the Solution Explorer has a project and I can finally see all files. This was weird. Thanks everyone tho!

TFS 2017 Deploy ASP .NET Core

We are on TFS 2017 initial release (on premise install). I am looking to see how I can build ASP .NET Core 2.0 apps using TFS 2017 Build / Release. Right now our standard builds uses Visual Studio builds and we have visual studio 2015 installed on our build server.
When I am attempting to build ASP .NET core 2 MVC app, using Visual Studio build, the build is failing with an error message :
Trunk\xxxxxx.csproj (1, 1)
Trunk\xxxxxx.csproj(1,1): Error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
Can I ask what is the recommended approach to building / deploying .NET core 2.0 projects using TFS 2017?
Install VS 2017 on the build server? We already have VS 2015 installed on the build server. Can VS 2015 and VS2017 live side by side on the build server and will the VS build step pick up 2017?
Visual Studio Builld
Or should we be installing .NET core 2.0 SDK on the build server and then use command line utility as a part of the build step.
Or should we switiching to MSBUILD instead of VS studio build and installing just the MSBuild for VS 2017 on the builld server.
1.You could install VS2017 on the build server. VS2017 and VS2015 could live side by side on either a build server or a develop machine. You just need to select which version you will use in visual studio version picklist. However VS2017 option is not support on the build-in Visual Studio Build task on TFS2017. It's not related to VS2017 installed on the build server or not.
2.You need to install .NET CORE 2.0 SDK on the build server, otherwise will get a similar error as below:
error : The version of Microsoft.NET.Sdk used by this project is
insufficient to support references to libraries targeting .NET
Standard 1.5 or higher. Please install version 2.0 or higher of the
.NET Core SDK.
Highly recommend you to keep the build server environment as same as local develop machine, this will narrow down the build issue on TFS.
3.No you don't have to. Just follow the process in this tutorial-- Build your ASP.NET Core app
Suggest you update your TFS 2017 initial release to the latest version TFS2017 update2. This will include VS2017 in the picklist of vs version. And since .NetCore 2.0 released in May 2017 which is later then the initial TFS2017(November 2016), not sure if it's supported or have any other issues. However, one thing is certain: you could build .NET Core 2.0 apps in TFS2017update2 successfully. Moreover, there are many new features released with update2 version, there is no reason to stay on the initial TFS2017.

ASP.NET compiler fails with an XmlSerializers error, during web-deployment project

We're using Visual Studio 2010 Web deployment projects to compile web-application websites during our build. Visual Studio 2010 is not installed on our build-agents. We get an error (see below) during the build relating to the automatically-generated Foo.XmlSerializers.dll being built with a runtime newer than the currently loaded runtime and cannot be loaded by aspnet_compiler.exe.
We're targeting .NET Framework v3.5 in our project files.
Here's the error (reformatted for long lines):
"C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj" (Build target) (1) ->
(AspNetCompiler target) ->
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly
'Foo.FrontEnd.Site.XmlSerializers' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded.
[C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj]
I was having a similar issue, with the same error message, and after lots of frustration found the solution (which hopefully will give some ideas for this).
Here we have a build server with Windows SDK 7.1 (and 6.1 from when using Vs 2008) building VS 2010 projects targeting .NET 3.5. The web projects are then pre-compiled with aspnet_compiler (from v2 as per http://msdn.microsoft.com/en-us/library/ms229863.aspx#findingthecorrectversion). During pre-compilation I received the same error message as yourself for a project (not web, just normal library) with a web reference to a web-service. It looks like Windows SDK 7.1 doesn't set up the registry paths correctly for using .NET 3.5 tools (while Visual Studio does). This caused the web references to be compiled with a target runtime of .NET 4 (validated using reflector) so aspnet_compiler v2 had a fit. I compared the registry settings of the build server and my local visual studio install which showed the .NET 3.5 configuration for SDK 7.1 was not good, so I corrected the build server with the below. My guess is the web reference xml (in the non-web project) was being precompiled with sgen for .NET 4 as a fall back for not using the correct .NET 3.5 sgen. Once the registry change was applied everything was fine (the below didn't exist in my build server registry so I created it).
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx35Tools-x86]
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
Just as an aditional note I also used WindowsSdkVer to set 7.1 as the default SDK.

Error: This assembly is built by a runtime newer than the currently loaded runtime

I have downloaded published (code behind files are no there, combined with dll in bin folder) web application from Window Server 2008 where it is hosted, and open it with Visual Studio when I debug that application it shows following error:
"Could not load assembly because this assembly is built by a runtime newer than the currently loaded runtime"
I don't know how can I solve this problem and test application locally.
Please help me.
This errors happens when the DotNet framework you are using is of older version than the one used to build the assembly. You need to check which version of framework is used to build those assemblies and then use the same or higher to debug too.
I was getting this same error when running an installer for a Windows service, even when running the installer on the PC the installer was built on.
It turned out that although the Windows service project had been updated to .NET 4.5, the Setup project that was making the installer was still set to use .NET 2.0.
To check if the Setup project is using an older version of .NET than the project to be installed, in the Visual Studio Solution Explorer:
Expand the Setup project;
Under the Setup project, expand Detected Dependencies;
Under Detected Dependencies select Microsoft .NET Framework and check the Version property. Select the appropriate .NET version from the dropdown list;
Re-build the Setup project to create a new version of the installer.
This error can have a lot of other reasons, too. I had the same problem, and nothing helped until I stumbled across this:
TlbExp.exe error:This assembly is built by a runtime newer
I just ran into this issue when the assembly was built with a target framework of .NET 4, and v4.0.30319 was installed on the server, and other 4.0 apps were running successfully.
The problem arose because the app had originally been built targeting 2.0, and new 4.0 assemblies were pushed, but not the app.config file, which we generally update separately.
This means the supportedRuntime attribute was not updated in the config and caused the error. Adding the following to the app.config fixed our issue:
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
One the the assemblies reference in the project might be built using a newer version of .net, check version of every assembly reference and correct accordingly.
Also check the application pool that this web site is running as. It could be framework 2.0 default on some older windows servers. Change it to framework 4.0.

Visual Studio 2010 build with wrong framework

I'm working on Visual Studio Profesionnal 2010.
In my solution I've got 2 projects
The first is a web site with targeted .net runtime 2.0
the second is a dll with targeted .net runtime 2.0
I add the output of the second as assembly of the first.
I build and rebuild and clean my solution
result : Build succeeded
But when I launch the projet in my web-browser ( in debug or release ).
I've got the Server Error :
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded
Is there someone who had already the problem?
I think it can be a bug from Visual Studio 2010 but the hotline is very expensive
300€ the phone call.
More Information :
I opended my dll with reflector and saw that mscorlib is referenced 2 times
the first time Version = 2.0
and the second time version = 4.0
Open the .csproj file with text editor (e.g. Notepad) and see the references in there.
If there are references to frameworks higher than 2.0 remove them or change to 2.0 if possible, save and reload the project.
I am pretty sure that this means that you built with asp.net framework 3.5x, but your server only has 3.0x. Update the runtime on the server.
Your server can only support 3.0, Updating the server will resolve the issue..

Resources