My application builds and publishes Ok., without any reported errors, but when I try to load it from mi local IIS, I get the "Could not load file or assembly" error message.
I have read several posts on this forum about the mentioned error message and could not find a solution to my case.
Can any one help?
The complete error message says:
Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'QYS_Web' could not be loaded.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = QYS_Web
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: QYS_Web | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e22c2559/92c7e946/QYS_Web.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e22c2559/92c7e946/QYS_Web/QYS_Web.DLL.
LOG: Attempting download of new URL
file:///C:/inetpub/wwwroot/bin/QYS_Web.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118
[ConfigurationErrorsException: Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11396867
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
+1087
[HttpException (0x80004005): Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373
I checked and an updated version of my dll (QYS_Web.dll) is found in C:\inetpub\wwwroot\bin.
Before adding the custom culture, my application ran ok. when executed from the local IIS.
If I run it inside the IDE it works ok. (Except for some aleatory "attempt to read protected memory" errors that have been present ever since I began using VS 2010 Ulimate).
SergioTorres...
Member
7 Points
17 Posts
Could not load file or assembly
Jan 19, 2011 02:24 AM|LINK
I am developing a webforms application.
After I added support for a custom culture as per http://msdn.microsoft.com/en-us/library/ms172469.aspx, I am receiving an error message when trying to run my webforms application on my local IIS (Windows 7 Pro).
My application builds and publishes Ok., without any reported errors, but when I try to load it from mi local IIS, I get the "Could not load file or assembly" error message.
I have read several posts on this forum about the mentioned error message and could not find a solution to my case.
Can any one help?
The complete error message says:
Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'QYS_Web' could not be loaded.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = QYS_Web
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: QYS_Web | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e22c2559/92c7e946/QYS_Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e22c2559/92c7e946/QYS_Web/QYS_Web.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/bin/QYS_Web.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118
[ConfigurationErrorsException: Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11396867
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087
[HttpException (0x80004005): Could not load file or assembly 'QYS_Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4784373
eikden
Participant
906 Points
180 Posts
Re: Could not load file or assembly
Jan 19, 2011 04:46 AM|LINK
Please check your dll whether add into your references folder/bin folder.
Yeoh Eik Den, MCPD | MCSE
Blog: www.eikden.net
My Linkedin Profile
Please mark as answer if I answer your question.
SergioTorres...
Member
7 Points
17 Posts
Re: Could not load file or assembly
Jan 19, 2011 05:11 AM|LINK
Thank you for your answer eikden,
I checked and an updated version of my dll (QYS_Web.dll) is found in C:\inetpub\wwwroot\bin.
Before adding the custom culture, my application ran ok. when executed from the local IIS.
If I run it inside the IDE it works ok. (Except for some aleatory "attempt to read protected memory" errors that have been present ever since I began using VS 2010 Ulimate).
SergioTorres...
Member
7 Points
17 Posts
Re: Could not load file or assembly
Feb 07, 2011 02:31 AM|LINK
With the help of Microsoft Tech support I found the problem was the build action for the resource files with the localized strings.
I had the build action set to "embedded Resource". As soon as I set it to "Content" my application loaded ok.
I hope this helps.
570Enrico
Member
4 Points
7 Posts
Re: Could not load file or assembly
Jun 27, 2011 08:44 AM|LINK
Hi
i have the same problem. Where can i found "embedded Resource"? Inside a Web Application?
Thanks in advance
Enrico
SergioTorres...
Member
7 Points
17 Posts
Re: Could not load file or assembly
Jun 27, 2011 05:57 PM|LINK
Hi Enrico,
Open your solution in VS.
Click on the resource file in Solution Explorer (for example, Strings.es.resx).
You'll see in the properties windows, under "Advanced", the property named "Build Action".
Select "Content" as value for this property.
Hope it helps.