Could not load file or assembly 'App_Code' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Hi everyone,

I've been having a problem with the .NET application I'm working on ever since I started working on it last April.  My development computer runs Windows XP Pro 2003 64-bit Edition.  All of the projects in my solution are set to compile with the "Any CPU" mode.  I can run the application just fine in debug and release modes, but I've tried and tried to make it work when I publish it in inetpub/wwwroot and it just won't work.  I always get the following error :

 

Server Error in '/Requisitions' Application.

Could not load file or assembly 'App_Code' 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 'App_Code' 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 'App_Code' could not be loaded.

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = App_Code
 (Partial)
LOG: Appbase = file:///c:/inetpub/wwwroot/Requisitions/
LOG: Initial PrivatePath = c:\inetpub\wwwroot\Requisitions\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\inetpub\wwwroot\Requisitions\web.config
LOG: Using host configuration file: \\?\C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\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/v2.0.50727/Temporary ASP.NET Files/requisitions/833f9d68/80608f77/App_Code.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/requisitions/833f9d68/80608f77/App_Code/App_Code.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/Requisitions/bin/App_Code.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Stack Trace:

[BadImageFormatException: Could not load file or assembly 'App_Code' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +465
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +181
   System.Reflection.Assembly.Load(String assemblyString) +42
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

[ConfigurationErrorsException: Could not load file or assembly 'App_Code' 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) +3642024
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +402
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +155
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +36
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +235
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +214
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +57
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +259
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +406
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +125
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +203
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +52
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +50
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +514
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +274


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

Well, I said it never works, well it does work on computers who run Windows XP 32-bit without any problems.  I also manager to get it working on my computer by doing the following :

http://support.microsoft.com/kb/894435/en-us

ASP.NET 2.0, 32-bit version

loadTOCNode(2, 'moreinformation'); To run the 32-bit version of ASP.NET 2.0, follow these steps:

1. Click Start, click Run, type cmd, and then click OK.
2. Type the following command to enable the 32-bit mode:
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
3. Type the following command to install the version of ASP.NET 2.0 (32-bit) and to install the script maps at the IIS root and under:
%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
4. Make sure that the status of ASP.NET version 2.0.50727 (32-bit) is set to Allowed in the Web service extension list in Internet Information Services Manager.

The problem is that I can't remain in that mode, because all of my other apps don't work when I do it, only the one that I wanna be able to use.  I switched back to the 64-bit mode and all of my other apps started working again except for the one specified in my error message.

I've tried absolutely every trick that was suggested on these forums as well as everywhere else, and absolutely nothing seems to work.

Here are some of the things I tried :

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2679445&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=665884&SiteID=1

http://support.microsoft.com/default.aspx?scid=kb;en-us;329065

http://blogs.componentone.com/CS/forums/t/74096.aspx

http://www.dotnetjunkies.ddj.com/Forums/ShowPost.aspx?PostID=1633

 

All of our other apps work fine on both 32-bit and 64-bit platforms.  I compared them with the one that doesn't work and I can't see anything wrong or different between the 2.

Any suggestions?  I'm desperate...   

 

Thanks a lot in advance!

0
blakthorn
7/28/2008 3:56:45 PM
asp.net.config-deploy 12495 articles. 0 followers. Follow

6 Replies
6675 Views

Similar Articles

[PageSpeed] 59

You said, "All of the projects in my solution are set to compile with the "Any CPU" mode.  " 

 

Because you want to run it on a 64-bit CPU, what happens when you set it to specifically compile for a 64-bit CPU instead of "Any CPU" and then publish to Inetpub\wwwroot ? 

0
Tom
7/28/2008 10:21:13 PM

Tom.NET:

You said, "All of the projects in my solution are set to compile with the "Any CPU" mode.  " 

 

Because you want to run it on a 64-bit CPU, what happens when you set it to specifically compile for a 64-bit CPU instead of "Any CPU" and then publish to Inetpub\wwwroot ? 

 

When I try that, it gives me another error message that I didn't see before... 

 

Error 110 Could not create activity of type 'Requisitions.Workflow.Approbation.ApprobationWorkflow.Workflow1'. System.IO.FileNotFoundException: Could not load file or assembly 'Requisitions.Workflow.Approbation.ApprovalExternalEvent, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Requisitions.Workflow.Approbation.ApprovalExternalEvent, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'
   at Requisitions.Workflow.Approbation.ApprobationWorkflow.Workflow1..cctor()

=== Pre-bind state information ===
LOG: User = xxxxxx_xx\xxxxxxx
LOG: DisplayName = Requisitions.Workflow.Approbation.ApprovalExternalEvent, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 9.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.Config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
 C:\Working Folder\Requisitions_TEST\Requisitions.Workflow.Approbation.ApprobationWorkflow 1 1 

0
blakthorn
7/29/2008 1:31:44 PM

Are you trying to publish the application to c:\Inetpub\wwwroot\ on your own computer or are you trying to publish to a web server (i.e. different computer)? 

You might try deleting all of the files in

C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/requisitions/

 

after publishing to c:\Inetpub\wwwroot\   

 

Are you sure you have the 64 bit version of the .NET Framework Redistributable Package?  Please click on:  http://www.microsoft.com/downloads/details.aspx?familyid=b44a0000-acf8-4fa1-affb-40e78d788b00&displaylang=en
0
Tom
7/30/2008 8:40:25 PM

Hi Tom,

Thanks a lot for replying to my post, I really appreciate it.

"Are you trying to publish the application to c:\Inetpub\wwwroot\ on your own computer or are you trying to publish to a web server (i.e. different computer)?"

I tried on my own computer (wwwroot) and also on a web server (different computer).  It doesn't work on my computer because of the fact that I'm running Windows 2003 x64, and it works on a distinct web server when the web server is not x64 (and it doesn't work if it is).

You might try deleting all of the files in

C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/requisitions/

after publishing to c:\Inetpub\wwwroot\

I tried multiple times to do that to no avail...

Are you sure you have the 64 bit version of the .NET Framework Redistributable Package?  Please click on:  http://www.microsoft.com/downloads/details.aspx?familyid=b44a0000-acf8-4fa1-affb-40e78d788b00&displaylang=en

Yes I am absolutely positive that it is the 64 bit version of the framework.  I had installed it myself and I just double-checked to make sure it was and it is.

There are 2 things that I forgot to mention...  My project uses the Microsoft Enterprise Library (v. 3.1.0.0) and also the AjaxControlToolkit.

 I read some more about that problem on various sites and someone mentionned something that seemed like an interesting lead. 

http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic35207.aspx 

Here's what he said :

"All,

I found the problem: I complied my code with the "Any CPU" setting, but the Enterprise Library is complied with the "x86" setting. When .NET runs my code and tries to load EntLibrary, it assumes the EntLibrary is also 64bit, thus cause the problem.

This http://blogs.msdn.com/jaiprakash/archive/2005/10/06/477645.aspx page has more information on this problem."

I then decided to grab the MS Enterprise source code and add it to my project (only the parts I need) to make sure it was compiled the right way.  Still didn't work...

Also, one thing that I need to mention is that we have another application that is very similar to the one I'm having trouble with.  It also uses Microsoft Enterprise Library AND AjaxControlToolkit and it runs perfectly fine both on 32-bit and 64-bit computers...  I even tried using the same DLLs (Ent. Library + Ajax) for the app that won't work (copied them from the other project that works regardless of the fact that the OS is 32-bit or 64-bit)., and it still didn't work.  I compared the way the compilation is done (x86, x64, Any CPU, Mixed Platform) and both are set to use "Any CPU".

I really don't know what's wrong with that other app...  Any ideas?  I'm seriously running out of ideas...

Thanks in advance!

0
blakthorn
7/31/2008 3:05:48 PM

bump

0
blakthorn
7/31/2008 3:06:45 PM

Which version of IIS are you using? 

According to http://support.microsoft.com/kb/894435  ,

"IIS 6.0 supports both the 32-bit mode and the 64-bit mode. However IIS 6.0 does not support running both modes at the same time on a 64-bit version of Windows."


According to http://learn.iis.net/page.aspx/201/32-bit-mode-worker-processes/  , IIS 7.0 can be configured to run 32 and 64-bit applications simultaneously.  According to this URL,

"Unlike previous versions of IIS, you can now configure specific worker processes to run in 32-bit or 64-bit mode independently of each other on the same server."


Because this troublesome ASP.NET application does run OK as 32-bit application, if you are using IIS 7.0 perhaps you can configure it specifically to run in a 32-bit application pool on IIS while all the others run as 64-bit. 

Read http://www.andornot.com/about/developerblog/2008/05/how-to-install-webpublisher-on-64-bit.aspx , especially Step 6, and it might help you set up a 32-bit application pool on IIS 7.0 where you can publish and run this troublesome application. 

Reading http://www.bibble-it.com/2008/06/09/32bit-web-app-inside-64bit-website-iis-70 might also help. 

0
Tom
8/5/2008 10:20:31 PM
Reply:

Similar Artilces:

Server Error in '/Webapp' Application. Could not load file or assembly 'System.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.
 10 minutes ago, my web app worked fine.  Now it appears broken and I hadn't touched the web.config file.  Anyone know what might be going on here?  I checked my web server's .NET folder (C:\WINDOWS\microsoft.net\Framework64\v2.0.50727) and there is indeed a system.data.dll file...  Could not load file or assembly 'System.Data' 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. Plea...

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Hello Experts, I have a ASP.net 2.0 application developed in Visual Studio.net 2005 which was working like a charm. Now I opened the solution in VS.net 2008 and though it is building successfully, when I try to browse it I am getting this error Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format. First of all working in Vista is a big pain with all the crappy stuff we need to do for every small thing. I would really appreciate your help on this guys. ...

IIS + .NET 3.5 Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
 Ok folks I need some help here. I have MS Server 2003 with IIS installed. Frameworks 2.0, 3.0 & 3.5 installed. The server has VS 2008 Web Developer installed because I am developing on it remotely. When I run the web site from inside VS everything is fine. I created a new website in IIS (named Intranet) and set it to run on Framework 2.0 and set the path to the root folder of the site (D:\Intranet). I also confirmed that VS was building for framework 3.5. When I open Internet Explorer on the server and go to http://localhost/Intranet I get the following error: "Could not ...

could not load file or assembly 'Microsoft.Web.Extensions.Design' or one of its dependencies.The located assembl' manifest definitation does not match the assembly reference.
 Hi All,  I have got problem while deploying in windows server 2003.When I run deployed site I get this error,The error message is "could not load file or assembly 'Microsoft.Web.Extensions.Design' or one of its dependencies.The located assembl' manifest definitation does not match the assembly reference." Please help me to find the solution. Regards,Shiva Reddy.P v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} ..shape {behavior:url(#default#VML);} Normal 0 false...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Hi All,  Got a bit of a strange one. I have been building an ASP.NET 2.0 app now for quite a while and had everything working quite well untill my computer froze when running the app from the debugger. Now i get the following error message Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))  I have reinstalled Ajax 1.0, reinstalled the toolkit vsi, copied the web config from a working ajax site. Not sure what else to do, its strange that it suddenly hap...

Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070)
 I have a 2.0 application hosted in IIS 6.0 in windows 2003 OS . The application works fine 90% of the time .For balance 10% time , it keeps throwing Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070)  errorAssembly Load Trace: The following information can be helpful to determine why the assembly 'App_Code' could not be loaded.  WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Mic...

Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10618.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does
Hi, We just upgraded our application to .Net 3.5 from .Net 2.0. I updated the ajaxcontroltoolkit.dll to the corresponding version for .net 3.5 but we are getting the following error: "Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10618.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"  I tried to work around this using bindingredirect as following, but this did not solve the problem as I am stil...

Could not load file or assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does n
Hello All,If this is a repeat of posting that have been created, I sincerely apologize.  I have been looking for a solution for quite some time and although I have run across a lot of different posts offering solutions, nothing seems to be work.  Here is my dilemma:I have created a website with several pages using ASP.NET 2.0 and AJAX Extensions (including the AJAX Control Toolkit).  The pages run fine on my Development machine but on my IIS machine, I continue to recreate a Parser Error in regard to System.Web.Extensions.  Here is what I have done thus far: I have a...

Access is denied. Could not load file or assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Hi, everyone, I made a page in asp.net and worked well, I published it in hosting and walked, after working and it throws the error to me: “Could not load cases out or assembly “App_Code, Version= 0.0.0.0, Culture=neutral, PublicKeyToken=null” or one of its dependencies. Access is denied.” I return to republicar and works.  Somebody has some idea that it is happening? Hi I get the same message in a similar situation, did you find a solution?Bw. Mark ...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
Hi, I am using Visual Studio 2008.  I have installed AJAX and have the ajaxToolkit.dll within my bin folder.  I am able to drag all the AJAX items into my page. I am launching my Visual Studio application through a URL which is hosted on a web server.  My web.config file is not within the solution but within the root of the folder. I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser ...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
Ive just started to transfer the website to the server and i keep getting this error "Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified." It works fine in VS, and the AjaxControlToolkit.dll is in the bin directory.  Ive added the assembly reference to the config:<controls> <add tagPrefix="AtlasControl" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" /></controls> Any suggestions?      I'd guess that maybe the web server doesn't have ASP.NET A...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified
Hi,How do you install the ajax control toolkit on a computer that does not have visual studio or visual web developer installed?It is running asp.net and the ajax extensions appear to be installed correctly too. I have tested pages on my local machine, which has the toolkit installed properly (and has visual web developer installed too). However when I try looking at the pages on the server, I get this error"Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified"Do I need to register the assembly? How do I ...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified. #2
 hii am new to asp.net and asp.net  AjaxControls, pls help this error below. Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.Source Error: [No relevant source lines]Source File: none    Line: 0 Asse...

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified #2
"Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified"Here's the source code that's causing the error: Line 1: <%@ Page Language="VB" %> Line 2: <%@ Import Namespace="System.Net.Mail" %> Line 3: <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> Okay, I have the dll's loaded and everything and I keep getting this error. I am trying to use the ValidatorCalloutExtender of the Beta. Any ideas?John WootonInspireMedia http://www.inspiremediablog.co...

Web resources about - Could not load file or assembly 'App_Code' or one of its dependencies. An attempt was made to load a program with an incorrect format. - asp.net.config-deploy

Resources last updated: 1/5/2016 9:01:13 AM