All of a sudden my website is throwing this error message when I try to debug it within Visual Studio. If I deploy the website, it works without any errors.
Any suggestions to resolve this error.
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Win32.Primitives' 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.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290 System.Web.Compilation.BuildManager.ExecutePreAppStart() +157 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531 [HttpException (0x80004005): Could not load file or assembly 'Microsoft.Win32.Primitives' 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.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946132 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
Try delete that section from your web.config
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
</dependentAssembly>
If you are working with .NET Core, and have this:
using System.Data.SqlClient;
Then, switching it to this is a potential solution:
using Microsoft.Data.SqlClient;
I had this problem, but with System.Runtime
specified in the error message:
[BadImageFormatException: Could not load file or assembly 'System.Runtime' 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)]
I found that thoroughly cleaning the solution and rebuilding fixed this problem for me. And just doing a Visual Studio Clean wasn't enough. I actually had to delete my \bin
folders as well.
Delete the \bin
directory, Rebuild your project.
i have deleted existing code based from local and again cloned the code. afterword its started working for me.
User contributions licensed under CC BY-SA 3.0