Folks, this may have been asked before, i took some time trying to search for a possible root cause/solution to this but have not found anything similar enough.
Goal: I am looking to publish a Dockerized .Net Core Web App default template to an Azure Container Registry.
I have created a default application teplate for .Net Core Web App using Visual Studio 2022 targeting .Net 7.0. this is what it looked like:
i have tested running it locally on my machine which seems to be working just fine.
i then went ahead and created a publish profile targeting Azure Container Registry.
when i attempt to run the publish workflow - it seems to run into an error complaining that:
error from sender: context canceled
C:\FolderPath\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.17.0\build\Container.targets(219,5): Error MSB4018: The "ContainerBuildAndLaunch" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
It also complains about Assembly binding logging being turned OFF. i went on to fix this issue however it had no effect on the original error about the missing file related to Microsoft.Win32.Registry.
I have tried to add Microsoft.Win32.Registry nuget package to the project explicitly. That did not solve the problem either.
I have tried to reproduce these steps on another computer workstation running different Visual Studio (Professional edition as opposed to Enterprised) and on the other computer - i am able to deploy dockerized template to Azure Container Registry just fine.
At which point i have decided i would do a full re-install of the computer system where i had a problem (it was due anyway for a while and i was putting it off). So i did a fresh Win 11 install, fresh VS install and fresh Docker Desktop install among all other things. i intentionally tried to stick to default config whenever possible.
after full reinstall - i keep hitting the same error.
i would appreciate any hint as to what might be causing the error. thank you!
Try copying the lib\net461\Microsoft.Win32.Registry.dll file from the Microsoft.Win32.Registry NuGet to C:\FolderPath\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.17.0\tools\.
I haven't been able to reproduce the issue. But if copying the file unblocks you, I can update the NuGet to include it going forward.
I have a web project, which works fine on local PC. But when I publish it on Azure Website, I get an error:
Could not load type 'Infrastructure.Asset.AssetContext' from assembly
'Infrastructure'. Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack
trace for more information about the error and where it originated in
the code.
Exception Details: System.TypeLoadException: Could not load type
'Infrastructure.Asset.AssetContext' from assembly 'Infrastructure'.
where AssetContext is DbContext from another project inside solution. As I understand, this assembly is not published correctly on Azure. So, I removed all files on Azure Website via Kudu and republish again. The same. I try to connect to remote Db from my local - it works. I tried to rebuild solution, reopen Visual Studio etc. Nothing happened
Why it can be happened, what is wrong and how to fix?
There is a similar SO thread What could be causing a System.TypeLoadException in a Visual Studio Unit Test?, I think which answers are valuable for your current issue.
Please follow the figure below to get the information of what platform you used is on Azure Website, then to select the current mode in Visual Studio to build and publish.
I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:
This error occurs when a CGI application does not return a valid set
of HTTP headers, or when a proxy or gateway was unable to send the
request to a parent gateway. You may need to get a network trace or
contact the proxy server administrator, if it is not a CGI problem.
Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).
For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.
Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.
EDIT
When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'Microsoft.AspNetCore.Hosting.Abstractions,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?
the issue was actually coming from the fact that, at first, my web app was using .net core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp.net core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.
This is explained in more details here: https://github.com/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550
Others have explained the reason why this is happening. I'd like to provide another – arguably easier – solution to the problem.
Just change the settings so that you remove files that are already on Azure – see below:
Check for log files either in the portal or by remotely accessing D:\home\LogFiles.
Sometimes, the logs won't indicate what is going wrong. Another good way to investigate further is to try launching your ASP.NET Core app from the Debug Console. If you are missing a shared framework version or there is another startup error, this will be more visible from the Debug Console.
Go to
https://(your web site name here).scm.azurewebsites.net/DebugConsole/
Your site will be in D:\home\site\wwwroot. You can launch it by executing:
cd D:\home\site\wwwroot
dotnet MyWebApp.dll
If you app still fails to launch, make sure that D:\home\site\wwwroot\web.config is available and configured to use ASP.NET Core Module. https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module
In my case, It was caused by having a space in the Project Name.
I can readily add a space, publish => 502.5.
Remove space, publish => good to go.
Hard to believe but I am duplicating it readily with above.
Also using "Remove Additional Files at Destination" per #Sam's Answer
See https://github.com/Azure/app-service-announcements/issues/14
"The rollout is expected to complete by Friday June 30th."
In my case the issue occurred because AppService at that time supported 2.0.0-preview2-006497 but I had 2.0.0-preview3-006890 installed which was used on build.
So I added global.json to use preview 2 SDK and it worked then
I don't know if this could help someone one day but in my case, I was using :
-Microsoft.AspNetCore.All 2.0.5
Downdrage to Microsoft.AspNetCore.All 2.0.3 resolve my problem
This happens when your version of ASP.NET Core cannot be matched on the server.
The simplest solution is to change your settings to deploy the app as self-contained, so it doesn't matter if Azure can match the framework version. Also, delete the files already on Azure, so you don't have issues when upgrading, as explained by #Sam.
It has been a while since I've published my app to Azure. During that time frame, I've upgraded my system from 32-bit to 64-bit meaning a fresh install of Windows and Visual Studio. And Visual Studio Update 3 came out and was applied. When I went to publish an update today, I received the following:
The following exception was thrown trying to publish: Root element is missing.
My web.config file looks fine so I don't think it's this issue.
The app works fine in debug mode so I don't think it's any of the .lsml files as is mentioned here.
And I tried this procedure to hand edit the .ls3proj file but it didn't seem to help.
I previously had an issue trying to publish when I upgraded from the standalone LightSwitch 2011 to Visual Studio 2012. I was able to overcome that issue using the method described in this thread.
Attempting to use this same method resulted in my new project has a full screen error saying "There are critical errors in the application definition metadata..." and 210 individual errors (max errors reached).
The first error, "Cannot create unknown type '{http://schemas.microsoft.com/LightSwitch/2010/xaml/model}GlobalAttributeGroup'." Doesn't make sense because that line in the .lsml is identical from the old project to the new project.
The second error, "Could not find any application definition in the project." Which I do not understand at all.
I am able to publish a simple "Hello, world" style app to my Azure account.
What could be causing this? How can I get more information about exactly which element is causing the issue? The log produced by running devenv /log was not helpful.
Matt Thalman was able to solve my problem over in the Microsoft Forums. The ServiceConfiguration.cscfg and ServiceDefinition.csdef were missing from the project when checked out of version control. Copying those over from a new project restored my ability to publish.
I have created a cloud project with an MVC3 webrole (empty project, added homecontroller and view). When I debug(F5) it runs smoothly.
After installing DotNetOpenAuth 3.4.7.11121 via NuGet I get the following error:
Windows Azure Tools for Microsoft Visual Studio There was an error
attaching the debugger to the IIS worker process for URL
'http://127.255.0.1:83/' for role instance
'deployment16(82).WindowsAzureProject1.MvcWebRole1_IN_0'. Unable to
start debugging on the web server. See help for common configuration
errors. Running the web page outside of the debugger may provide
further information. Make sure the server is operating correctly.
Verify there are no syntax errors in web.config by doing a Debug.Start
Without Debugging. You may also want to refer to the ASP.NET and ATL
Server debugging topic in the online documentation.
Same thing happens on an MVC2 project on another machine.
Boils down to the following line of configSections in web.config (added by install-package DotNetOpenAuth)
<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
What am I missing?
Seems like the mentioned line above from web.config can be deleted. Probably already included in machine.config or something.
And, when i hit debug on the mvc project it runs as expected. The error only happens when i debug the cloud project
Seems like deleting the mentioned line (section name="uri"...) fixes things in both debug and without debug.
I have not discovered any ill effects and logon with OpenID against Google with dotNetOpenAuth works.