Could not load file or assembly 'System.Data.DataSetExtensions, Version=4.0.0.0PublicKeyToken=b77a5c561934e089' or one of its dependencies

1

Error Description:

Could not load file or assembly 'System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)'

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[BadImageFormatException: Could not load file or assembly 'System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)] 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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +225 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22 System.Reflection.Assembly.Load(String assemblyString) +34 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +69 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321 System.Web.Compilation.BuildManager.ExecutePreAppStart() +170 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734

[HttpException (0x80004005): Could not load file or assembly 'System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +708

Scenario :

This error popped up on the published app on IIS ,but the local copy works fine in the same machine .

Dev Environment :

Visual Studio 2017 , MS SQlServer 2014 , Entity Framework Code First .

Observation:

Newly published version has this error but previously published versions works fine. Local copy working fine without any issues in the same machine.

Tried:

Could not load file or assembly 'System.Data.DataSetExtensions, Version=3.5.0.0
[Could not load file or assembly 'System.Data.DataSetExtensions

sql-server
visual-studio
entity-framework-6
visual-studio-2017
sql-server-2014
asked on Stack Overflow Mar 25, 2018 by user2695433 • edited Mar 25, 2018 by Eray Balkanli

1 Answer

0

Posting solution which worked, as it might help somebody.

There was an optional Windows update related to SqlServer pending which I executed solved the issue.

Reason for the issue: And the issue was due to a Malware attack which needed a restoration to a previous working backup which might have corrupted the dll.

As the error message shows the dll was corrupted/damaged which can be confirmed by executing in PowerShell which confirms the error

([system.reflection.assembly]::loadfile("C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.DataSetExtensions.dll")).FullName 

Also, note that downloading and replacing the dll with the same version also didn't solve this. Even tried to remove and add reference from Visual Studio IDE which also didn't help.

answered on Stack Overflow Mar 27, 2018 by user2695433

User contributions licensed under CC BY-SA 3.0