VS2019 Must DELETE /bin folder and recreate in order for solution to debug

0

I have a VS2019 ASP.NET (MVC 5) Solution with which I must delete and recreate the /bin folder in order for the solution to compile and debug. Once I delete it, it runs fine until I restart (close/open VS & the project) and attempt to debug again.

I began getting this error with a move from Framework 4.6.2 to 4.8. All updates are current.

I get the following error when I begin a debug session:

Server Error in '/' Application.
Cannot load a reference assembly for execution.
...

[BadImageFormatException: Cannot load a reference assembly for execution.]

[BadImageFormatException: Could not load file or assembly 'System.IO' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +37
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +159
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +80
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +29
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

So the first thought is permissions, but all looks correct. Running the solution in admin does NOT change anything. I've repaired VS2019 but still to no avail.

I have a few other projects that run stable on Framework 4.8, although it was a bumpy ride getting them there, but for different reasons.

Has anyone experienced this and if so what fixed it? Thanks in advance for your help.

.net
asp.net-mvc-5
visual-studio-2019
.net-framework-version
asked on Stack Overflow Apr 7, 2020 by HumbleBeginnings • edited Apr 7, 2020 by HumbleBeginnings

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0