Error loading file or assembly in Web Application - asp.net

i need some pro help here,
I'm trying to install the DevInfo 7 Web application on my server, had A LOT of problems with SQL Server and IIS, after 2 days, i managed to fix it, but now that IIS and SQL are working fine, i can't get past this error because i have no idea about this language (btw, i'll add some tags, but as i don't know this language, i'm not sure they are actually related to the question, if i chose a tag wrong, tell me that i take it of!)
If somebody can explain to me what's wrong, or how to fix it, i would appreciate, as i'm not creating a Web Application (i have no idea on how to do so), and only trying to install one, i may not understand (please be as simplistic as you can)
I dunno if this changes something, but i'm installing it on a Windows Server 2012, x64...
Here's the error:
Server Error in '/devinfo' Application.
Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'DI5_INIFile' 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 'DI5_INIFile' 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, 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) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122
[ConfigurationErrorsException: Could not load file or assembly 'DI5_INIFile' 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) +12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

It sounds as if you have entered .net Version Hell. I've had this problem when there are conflicting dll versions.
Things to try:
1 - Clean your solution (Right click on the top of the solution tree in Visual Studio and click "Clean"), then do Rebuild All.
2 - If that doesn't work, clean out the ../bin/Debug folder for you project, and repeat step 1. If this is a web application and you have a local version of IIS running, you should consider doing an IIS reset first. This will release any locks that processes may have on dlls in your bin folder.
3- In addition to step 2, you could clear out the ../obj folder too. The clean and rebuild should do this for you, however.
4 - One more thing to try is clear out the temporary asp.net files:
del /F /Q "%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"
5 - Failing that, you will need to look at which project is trying to reference 'DI5_INIFile' and check its version number (right-click on the dll > properties > version) and see if it's in your web.config under a different version number.
If it is, you could remove the referenced assembly from your project and try to re-add it again.
Hope that helps!

Related

Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found

I've seen the ticket “Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies” by Harsh Gupta and I'm having the same problem but without those solutions working for me.
I have an web application including ImageMagick that is freshly installed on a new Windows Server 2012 instance (that we're migrating to from a Windows Server 2008 R2 instance). The application runs ok on Server 2008 and locally, but not on Server 2012.
I have rebuilt the project after upgrading Magick.Net from 6.8.7.502 to 7.0.7.300, in the hope that the .Net Standard / .Net Core support mentioned in the Readme, introduced in 7.0.6, would solve my problem, but to no avail. Before doing that, I had also installed VC++ 2012 and 2015 as Harsh Gupta mentioned in their accepted answer.
Despite all this, I'm still getting a "HTTP Error 500.0 - Internal Server Error" page, telling me:
Module: AspNetInitializationExceptionModule
Notification: BeginRequest
Handler: ExtensionlessUrlHandler-Integrated-4.0
Error Code: 0x00000000
Requested URL: [redacted]
Physical Path: [redacted, but correct]
Logon Method: Not yet determined
Logon User: Not yet determined
The Event log shows a Warning event from ASP.NET 4.0.30319.0 with an Event ID of 1310 and the following Stack trace:
Event code: 3008
Event message: A configuration error has occurred.
Event time: 9/20/2017 6:20:40 PM
Event time (UTC): 9/20/2017 6:20:40 PM
Event ID: 4775ecdb4601401ca30aa057f77ae78a
Event sequence: 1
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: [redacted]
Trust level: Full
Application Virtual Path: /
Application Path: [redacted]
Machine name: [redacted]
Process information:
Process ID: 5096
Process name: w3wp.exe
Account name: IIS APPPOOL\[redacted]
Exception information:
Exception type: ConfigurationErrorsException
Exception message: Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
Request information:
Request URL: [redacted]
Request path: /
User host address: [redacted]
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\[redacted]
Thread information:
Thread ID: 8
Thread account name: IIS APPPOOL\[redacted]
Is impersonating: False
Stack trace: at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Custom event details:
Looking in the webroot, the bin folder does contain Magick.NET-x86.dll (and Magick.NET-Q16-x86.dll and Magick.NET-Q16-x86.Native.dll), and the IIS_IUSRs group does have read access to these DLLs (and all the others).
While it is a 64-bit server, the AppPool does have Enable 32-bit applications set to True. Changing the AppPool's Managed Pipeline Mode from Integrated to Classic also has no effect. I do note, however, that the number of applications for the AppPool is listed as zero (despite the website's advanced settings dialog showing the correct AppPool name):
I am completely at a loss and we are behind schedule on the migration of this application now, so any suggestions would be gratefully received.
Thanks!
Edited to add: There is a little more information at ticket #107 on Github.
I don't have an answer but a few ideas on troubleshooting, although you probably tried these.
You mention the apppool isn't showing the application. Try recreating the apppool or using one of the preexisting apppools as a temporary option to see if there was an issue with apppool.
You're using apppool I'd, which is best but does changing to network service account help, if so points at permission issue.
Have you compared installed Windows features on the old and new servers? Just wondering if it requires WCF.
Has the bin directory been given execute perms in iis.
Do basic aspx pages work or is the configuration breaking those as well.
Maybe you've tried all that but hopefully it might help give you another direction, even if it doesn't help directly.
Try using the Global Assembly Cache Tool (gacutil.exe) to publish the missing assembly to the GAC:
gacutil.exe /i Magick.NET-x86.dll /f
gacutil.exe /i Magick.NET-Q16-x86.dll /f
gacutil.exe /i Magick.NET-Q16-x86.Native.dll /f
The .NET runtime scans for assemblies in the GAC when it cannot locate an assembly referenced by the project at a local path. We typically use the GAC for assemblies shared by several applications, but we can try this approach for troubleshooting.
If the application in question runs successfully after publishing these assemblies to the GAC, there may be a problem with the assembly reference properties in the project that uses them.
After testing, we can remove the assemblies that we added from the GAC:
gacutil.exe /u Magick.NET-x86
...
gacutil.exe comes with the .NET Windows SDK. To avoid installing this on the server, we can use PowerShell to install the assemblies:
[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") > $null
[System.EnterpriseServices.Internal.Publish] $publisher = new-object System.EnterpriseServices.Internal.Publish
$publisher.GacInstall('Path\To\Magick.NET-x86.dll')
Both tools require administrator privileges on the server.
In a separate conversation on Github with the creator of ImageMagick, we eventually got to checking the version numbers of DLLs, which led us to realise that — as well as the expected files Magick.NET-Q16-x86.dll and Magick.NET-Q16-x86-Native.dll both at version 7.0.7.300 — there was also a file Magick.NET-x86.dll that is version 6.8.7.502.
Quoting Dirk Lemstra directly:
The Magick.NET-x86.dll file is an old file that should not be there. Can you remove that file and check if that resolves your issue? I apologize for not noticing this much earlier.
You no longer need to install the C++ redistributable. The necessary libraries are statically linked which means that you don't need to install that anymore.
Removing that superfluous file has solved the problem. 🎉

Dependencies not loading or partially loading

I am trying to work with the MS Lync UCMA 4.0 sdk and just switched to using Visual Studio 2012 (becuase .NET 4.5 Framework is required). I can't figure out what is going on here, I've set the Target CPU to x64 and the Target Framework to .Net Framework 4.5 because I was getting the error:
"Could not load file or assembly 'SIPEPS, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
Now that I've made these changes I get the below error.
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Azure' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Azure' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Azure' could not be loaded.
=== Pre-bind state information ===
LOG: User = CREATIVE\kielhowell
LOG: DisplayName = Azure
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Azure | 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:/Visual Studio Projects/TPL/
LOG: Initial PrivatePath = C:\Visual Studio Projects\TPL\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Visual Studio Projects\TPL\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:/Users/kielhowell/AppData/Local/Temp/Temporary ASP.NET Files/root/186577b4/cde0def/Azure.DLL.
LOG: Attempting download of new URL file:///C:/Users/kielhowell/AppData/Local/Temp/Temporary ASP.NET Files/root/186577b4/cde0def/Azure/Azure.DLL.
LOG: Attempting download of new URL file:///C:/Visual Studio Projects/TPL/bin/Azure.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Azure' 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, 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) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Azure' 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) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): Could not load file or assembly 'Azure' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
I had a very similar problem. I found the problem was that it couldn't find the dependency, and I was able to find out which one by using a dependency walker.
Link
You can open your .exe here, and it'll point out what you're missing in your project. For me it was the Microsoft C++ redist.
I had a similar issue after I copied my test code from my local machine to the trusted application server. I had to remove the Microsoft.Rtc.Collaboration dll reference from the project and browsed it in the application server and re-linked it.

Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies

I am working on a web application which interacts with TFS. When I upload my application to windows azure cloud I am getting this error message .
appreciate your inputs to resolve this issue.
pasted below is the error message I am receiving
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' 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 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' 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) +123
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' 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) +11568240
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700976
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869205
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
This is because ,your project is trying to use a 32-bit dll in a 64-bit environment(azure)
To solve this type of issues ,create a start up script with the below given commands
Copy below startup script to a text file and save as "setup.cmd" .
Then include this file into your web role project,set "copy local"=true
then open your ServiceDefinition.csdef below given startup command inside webrole tag
<webrole > --your webrole
<Startup>
<Task commandLine="setup.cmd" executionContext="elevated" />
</Startup>
</webrole >
start up script pasted below:
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/applicationPools /applicationPoolDefaults.enable32BitAppOnWin64:"True" /commit:apphost
I resolved this issue by removig the respective DLL from the bin folder of my asp.net web project.
Thanks and regards,
I resolved this by setting the Enable 32-Bit applications option to True in the Advanced Settings of the application pool which the site used.
BadImageFormat Exception is almost always a problem between a 32bit dll trying to load up a 64bit dll or a DLL or executable is loaded as a 64-bit assembly, but it contains 32-bit features or resources.
Try compiling your application down to x86 or vice versa and let me know how that works

Strange and random occuring Assembly not found error

I did a simple ajax services (json based) to get some data from database.
The problem stated below:
On localhost: while programming/editing the aspx page in visual studio and seeing the result in browser it works fine for say 5-6 times of editing the aspx page, and then just start failing. Until I go to my web service interface class do something (say just put a newline somewhere) and recompile it. The problem get fixed and the cycle goes on...
When I trace the failed requests in fire bug I found 500 internal server error:
[FileNotFoundException: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
*full stack trace below.
I am not sure, but looks like this file 'App_Web_lbgnha4m' is generated temporary because everytime I fix this error by recompiling the code. After some time it again comes back with new name 'App_Web_blahblahblah'
My biggest concern is that when I deploy the solution to my staging server. the service worked fine (say for a day) and then same error, quite surprised what goes wrong without touching a file once deployed). Obviously I can’t deploy the solution every day to fix this....
Any suggestions please help......
Full Stack Trace:
[FileNotFoundException]: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
[ServiceActivationException]: The service '/Website/RESTfulService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'App_Web_lbgnha4m, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified..
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext)
at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Try switching to an ASP.NET Web Application project.

ASP.NET application developed in 32 bit environment not working in 64 bit environment

We have developed an ASP.NET website on a Windows 7 - 32 bit platform using Visual Studio 2008. This website is being hosted at a hosting company where we share a server with hundreds of other ASP.NET websites.
We are in the process of changing our hosting to a dedicated Windows 2008 - 64 bit server.
We have installed Visual Studio on this new server in order to debug our application.
If we try to start the application on this new server using Visual Studios 2008's own web server (not IIS 7) we get the error below.
We have tried to compile the application in both 32 as well as 64 bit mode. We also tried to compile to "Any CPU". But nothing helps. We also tried running Visual Studio as an administrator but without success.
We get the following error:
Server Error in '/' Application.
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232
System.Web.Compilation.BuildManager.CompileGlobalAsax() +51
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337
[HttpException (0x80004005): The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8897659
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259
Does anyone know why this error appears and how to solve it?
First of all, the error you are getting relates to a missing file, hence the FileNotFoundException. However, you are also getting HRESULT 0x8007007E, which points to a missing unmanaged DLL.
Here's how I would tackle this problem:
Step through the code to find where this exception occurs. With that HRESULT, I'm pretty sure you'll find the exception to be on a line where an unmanaged DLL function is called.
Identify what unmanaged DLL you're trying to use.
Check to see that it's there. First, you should check that any ones you are using are in their right places and are referenced correctly. If that is all OK, make sure that any dependencies they themselves have are there, too.
Also, after you complete step 2, we might be able to help you more if you tell us what type of unmanaged code you're using (i.e., what it might require to run, in terms of its own dependencies).
Hope I helped! :)
The error is not anything to do with processor-specific stuff. It is clearly a missing file that is causing this error. Have you double checked that you have all the required files and assemblies installed on the new dedicated server?
Does anyone of the error information indicate what module could not be found?
If not, verify the deployed bin directory has everything your site has when its working on your test server. Then go through the web.config and make sure all referenced modules are on the target server.

Resources