简体   繁体   中英

System.TypeLoadException: 'Method 'GetItem' in type 'Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProjectFileSystem' in asp.net core

In asp.net core when i add a line in program services.AddMvc().AddXmlSerializerFormatters();but error occur in the startup.cs at the Runtime moment please enyone can solve this error.

I ran into something similar when I was switching from core to full framework in a web app today. I ended up messing around with my nuget packages a bunch, unloading/reloading the project. I finally traced it down to the Microsoft.VisualStudio.Web.CodeGeneration.Design nuget package. It had 3.0.0 installed but all of my other Microsoft.AspNetCore.** were 2.* versions and I'm using net472. So, I removed that nuget package and the error went away. Then I changed it to version 2.2.4 and the error went away--so either solution worked for me. Hopefully this will fix your issue to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM