Using an existing .NET 5 MVC Web App, I attempted to upgrade to .NET 6, but encountered this error. I am also using IIS for Windows Authentication--now setup in .NET 6 as "profiles" under Properties -> Debug -> hyperlink (Open debug launch profiles UI). I also included the newer "Microsoft.AspNetCore.Authentication.Negotiate" Nuget package (and associated code) to handle the newer Windows Authentication library.
When the web app launches, I get the following error:
An unhandled exception occurred while processing the request.
InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List assemblies)
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions+<>c.b__0_0(CompilationLibrary library)
System.Linq.Enumerable+SelectManySingleSelectorIterator<TSource, TResult>.MoveNext()
...
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
This does NOT go away if I add the package listed: System.Security.Cryptography.Pkcs
I needed to remove at least 1 Nuget package:
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -- I removed this one second, but it started working after I did.
Microsoft.Extensions.Hosting -- I removed this one first, but this alone did not fix it. I don't know if this "also" needed to be removed. I assume not, but I'm including, just in case. Removing it did not hurt anything.
Edit: As a WARNING, this will lose the abilities given by Razor.RuntimeCompilation. However, there appears to be a code incompatibility with, I believe, IIS and Razor in .NET 6.
I get this error only when running application (piranha cms) inside docker container.
I had to remove razor runtime compilation to make it work.
// comment out or delete this line
// options.AddRazorRuntimeCompilation = true;
Related
I've got a project that I need to Migrate from .NET Framework to .NET Core. After migrating it I've noticed an exception –
Unity.Exceptions.ResolutionFailedException HResult=0x80131500
Message=Resolution of the dependency failed, type =
'LanDocs.ExchangeSystem.Server.Interfaces.IExchangeDataHandler', name
= '(none)'. Exception occurred while: while resolving. Exception is: InvalidOperationException - You cannot have more than one dynamic
module in each dynamic assembly in this version of the runtime.
What might be the issue and how to fix it?
I've figured it out myself and decided to share the solution here since I haven't found anything helpful while struggling with it.
The issue was with Policy Injection – once I've removed the entire section everything worked well.
But the problem was the version of version of nuget package. I've had Unity.Interception with version 5.5.3 and Unity with version 5.8.6. Once I've changed both versions to 5.11.1 everything worked well on .NET Core.
I get many error messages if I install the Xamarin.Firebase.iOS.CloudMessaging 3.1.2 nuget package.
Error: linker command failed with exit code 1 (use -v to see invocation)
Error MT5210: Native linking failed, undefined symbol: _FIRLogBasic. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
Error MT5211: Native linking failed, undefined Objective-C class:
FIROptions. The symbol '_OBJC_CLASS_$_FIROptions' could not be found
in any of the libraries or frameworks linked with your application.
Error MT5211: Native linking failed, undefined Objective-C class:
GULAppEnvironmentUtil. The symbol
'_OBJC_CLASS_$_GULAppEnvironmentUtil' could not be found in any of the
libraries or frameworks linked with your application.
Error MT5201: Native linking failed. Please review the build log and
the user flags provided to gcc: -ObjC
Error MT5202: Native linking failed. Please review the build log.
I tried uninstalling and reinstalling the nuget package but I still get the same errors.
I use Visual Studio Community for Mac 8.1.5 (build 9).
I need Xamarin.Firebase.iOS.CloudMessaging because I follow this tutorial: https://www.robbiecode.com/setup-push-notifications-with-firebase-in-xamarin-forms-for-ios/
What is wrong with my project? What can I do?
The following two projects are in my solution:
InapppurchaseTest.iOS, MonoGame.Framework.iOS (develop)
Well, this is a well-known issue with Firebase and Xamarin, what basically happens here is the old bin and obj files while interacting with the new data override some existing files that are needed by iOS to synthesize the IPA while deployment and hence ends up throwing linking RELATED errors, follow the below steps and it will clear this mess.
Clean bin and obj
Delete the builds in the following path of your MAC machine - ~/Library/Caches/Xamarin/mtbs/builds/ProjNAME where 'ProjName' is the name of the project you are currently working on
Once you are done with both the above steps add the Xamarin.Firebase.iOS.CloudMessaging package and change linker setting to Don't Link (this is for the time being)
After installing these packages see to it that you build your project dependency wise which means PCL'S and .Net standards first then the native iOS project.
Clean bin and obj again if it does not work for the first build...
This should solve your issues in case it does not repeat the above procedure.
EDIT
If you check the GitHub comment by SotoiGhost here, it says adding the below line anywhere in your project should solve this issue...
var foo = Firebase.Core.Configuration.SharedInstance;
Feel free to get back in case of issues
Good luck!
I am creating an Azure Function in C# using a target framework of netstandard2.0 in a Windows 10 environment. The function calls a method that's in another class library and that method creates an instance of SqlConnection. When I run the function I get the following exception:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: Functions.RefreshImages --->
System.Reflection.TargetInvocationException : Exception has been
thrown by the target of an invocation. --->
System.PlatformNotSupportedException : System.Data.SqlClient is not
supported on this platform. at
System.Data.SqlClient.SqlConnection..ctor(String connectionString)......
Obviously SqlConnection is supported on Windows so I assume there's something else going on here.
This happens when a .Net Standard lib that uses a SqlConnection is loaded dynamically via reflection. The .Net Standard lib will typically reference System.Data.SqlClient which seems to be a dummy lib without actual implementation. It apparently ensures that the lib will compile on all platforms, including those without Registry and other platform specific stuff that the real SqlClient implementation relies on.
The easiest solution I can find is to add a reference to the Microsoft.Data.SqlClient NuGet package in the host application (the .Net core application that dynamically loads the .Net standard lib).
You may see a small yellow warning exclamation icon in the Solution explorer because Visual Studio thinks you are not using the lib and if you use the "Remove Unused References" feature it will also suggest removing the package. There is a feature to suppress warnings in the PropertyGrid, but I cannot figure out wat number should be filled in since the warning does not appear in the error list when compiling...
It looks like this is related to loading a SQL connection via reflection in .NET core (you are running on netstandard2.0 but the principle should still be the same).
I just migrated an ASP.Net Core 1.1 application to the new 2.0 version that was just released. Now I get the following exception:
System.BadImageFormatException: 'Could not load file or assembly
'dotnet-aspnet-codegenerator-design' or one of its dependencies. An
attempt was made to load a program with an incorrect format.'
The exception is thrown on the following line (AddMvc):
public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
services.AddMvc(options =>
{
options.Filters.Add(new MiddlewareFilterAttribute(typeof(LocalizationPipeline)));
})
.AddJsonOptions(options =>
{
// Maintain property names during serialization. See:
// https://github.com/aspnet/Announcements/issues/194
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
})
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
}
I'm targeting the .Net Framework 4.7, using AnyCPU target platform. I'm using the win10-x64 RID if this is of any help.
Every Nuget package is up to date etc.
Any idea? I've got no luck by googling.
the same exception occurred when I switched from x86 to x64 (after upgrading from core 1.1 to 2.0).
Since dotnet-aspnet-codegenerator-design is not really needed at runtime, I removed that reference. But then an identical exception occurred with the Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv assembly.
Luckily, that problem was related to the fact I didn't change the .NET Core Runtime Identifier (RID). This was still set on win7-x86, so I changed it to win7-x64 and the Libuv devepency could load.
I hope there will be some fix for dotnet-aspnet-codegenerator-design since that dependency is probably necessary for scaffolding controllers and views...
Update: there is an issue for this on Github (https://github.com/aspnet/Scaffolding/issues/601)
There's a chance that the dependency is corrupted. You can use a tool like Everything (https://filehippo.com/download_everything/) to search and find the corrupt dependency. There's a good chance it will be somewhere in this folder (C:\Program Files\dotnet\shared). Once you find it, try to google and redownload it(there's a good chance, you'll find a nuget for it) and then replace the old\corrupt version (be sure to back up).
If you're having trouble finding a replacement for the dependency online, simply publish your project on to a folder, all the dependencies would be copied to that folder. If you publish your project, and you run dotnet PROJECTNAME.dll and you still get the same error, you might have to run a clean install or repair on Visual Studio.
I hope this saves someone a lot of time, this error can take a while to debug.
I was getting this error too on SmarterASP.NET hosting. I couldn't try all the file updates suggest here, but found another solution, prior to which I tried compiling to several targets without success. Finally, it all just started working when I targeted for Portable. On Smarter it is now running nicely as a Framework Dependent Deployment, ASP 2.2 Core, Portable. Sometimes I find getting Core running is like having to get out the ol' trial-and-error chops. As always, your mileage may vary.
I debug a site. I need to identify the .NET and ASP.NET version of the running site (on a local IIS).
When I have an .NET Error, the a page is displayed, like this:
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Unrecognized attribute 'requestValidationMode'.
Note that attribute names are case-sensitive.
Source Error:
Line 120: Line 121: Line
122: Line 123: Line
124:
Source File: C:\mysite\opt\root\web.config Line: 122
Version Information: Microsoft .NET Framework Version: 4.0.30319;
ASP.NET Version: 4.6.1038.0
Is there a way to obtain that data in other way than a error message, to be able to identify that versions at demand?
I would like to stress that .NET and ASP.NET are different, and I need both of them.
PS. I would prefer, if possible do not have to modify the code, but rather via IIS...
You can try either of this below
typeof(Page).Assembly.GetName().Version; //ASP.NET Version
This gives your running ASP.NET version which in my case 4.0.0.0. You can find the same information if you expand your Reference folder -> find System.Web dll -> right click and choose properties -> check the Version information.
System.Environment.Version.ToString(); //Framework Version
This gives the version information of the CLR.
.NET Framework - registry check?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
Environment.Version
should give you the ASP.NET version