"module could not be found" error with C++/CLI component in ASP.NET - asp.net

I have to include a (managed) C++/CLI component in one of my ASP.NET projects, that references for itself some other (unmanaged) C++ DLLs. Should be no problem - .NET 3.5 is happy when compiling the project, everything seems fine. The C++/CLI component and the other C++ DLLs are compiled by another department as Release version with "Any CPU" in Visual Studio 2005. The VC++ 2005 Redistributable package is installed. And the same code works without problem when I run it inside of a normal .NET console application.
Now while this code works in a console app, it's not being hosted correctly by ASP.NET - it leads an error on the initial page load (even before stepping into the Global.asax).
For testing and debugging, I have used two machine configurations:
Local Dev PC: Windows XP, 32 Bit, VC++ 2005 Redist Package, Visual Studio 2010, ASP.NET 3.5, Compiling "Any CPU", Hosting in Web Development Server (Cassini)
Test Server (target machine): Windows 7, 64 Bit, VC++ 2005 Redist Package, Hosting in IIS 7, AppPool has "Enable 32-Bit Applications" set
On both machines the same following error occurs when I start the ASP.NET application:
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.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Now this is weird... It doesn't say anything about what assembly is missing, even Fuslogvw.exe or sxstrace.exe aren't logging anything.
Moreover of coures it seems that the error depends on the C++/CLI assembly or on the unmanaged C++ DLLs. If I remove the C++/CLI assembly reference from my ASP.NET project and the code, it works fine. Now because the C++/CLI assembly depends on native C++ DLLs that are not referenced in the ASP.NET project, I copied all dependent C++ DLLs to the "bin" folder of the ASP.NET project's output folder (same as for the workgin console application). While every C++ stuff has been compiled in Release mode, with the correct VC++ Redist Package installed, there should be all dependencies in place. Of course I know there is a FileNotFoundException, but I cannot work out what's missing...
As said: the same code for accessing the C++/CLI component works in a .NET 3.5 console application on both test PCs (where I have the same dependencies deployed) with the same dependent C++ DLLs deployed into the output folder, just in ASP.NET I get the above error.
Any suggestions how I can get rid of the problem or how I can track it further?
(Of course I searched StackOverflow and Google for the problem, e.g. I found these links, but they didn't help:
- "The specified module could not be found" error when running C# ASP.NET web service referring C++ dll
- Access x86 COM from x64 .NET
- ASP.NET application developed in 32 bit environment not working in 64 bit environment
- Module Not Found Exception From .NET 2.0 Web Service On Windows Server 2008 R2 )

ProcMon saved me.
The path was my problem too. It seems that IIS is creating a shadow copy of each managed dll in C:\Windows\System32\inetsrv folder. But this in not the case for unmanaged code. When it has to load an unmanaged dll, it search the environmental path and not the bin directory of the application in IIS.
Many thanks Aristos!!

Your code reach the _nLoad and this is good because have pass all checks for loading and move to the core to actually load the dll, and there its fail.
For start download the Dependency Walker
from http://www.dependencywalker.com/ and use it on dll to find out what other resource this dll needs to run. I suspect that can not load some other dll files.
Additional maybe this dll search for other files that can not find and thats why can not load. The second way is to use the File Monitor, or the Process Monitor from sysinternals to find what fail to load.
http://technet.microsoft.com/en-us/sysinternals
http://technet.microsoft.com/en-us/sysinternals/bb896645

Related

Error loading file or assembly in Web Application

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!

On a 64-bit machine, cannot run the simplest web application when build on x64 platform (use vb in VS)

My scenario is that, I tried to build a very simple Asp.net web application, actually I did nothing but creating a new project of web (form) application using VB in visual studio 2012. Then, I changed the configuration to build it on x64 platform, and it always failed. But, if I change back to x86 platform, everything is fine. However, I do need a webapplicaiton built on x64.
When building it, no errors, but these warnings,
Rebuild All started: Project: WebApplication_debug, Configuration: Debug x64 ------
vbc : warning BC40010: Possible problem detected while building assembly 'WebApplication_debug': Referenced assembly 'mscorlib.dll' targets a different processor
vbc : warning BC40010: Possible problem detected while building assembly 'WebApplication_debug': Referenced assembly 'System.Data.dll' targets a different processor
vbc : warning BC40010: Possible problem detected while building assembly 'WebApplication_debug': Referenced assembly 'System.EnterpriseServices.dll' targets a different processor
vbc : warning BC40010: Possible problem detected while building assembly 'WebApplication_debug': Referenced assembly 'System.Web.dll' targets a different processor
Then, when I run it, I got,
Could not load file or assembly 'WebApplication_debug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 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 'WebApplication_debug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 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.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'WebApplication_debug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 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.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: Could not load file or assembly 'WebApplication_debug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 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) +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.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +307
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I have tried whatever I can, like setup IIS appPool, etc. No work out.
It sounds like you're trying to load it in a 32-bit webserver.
Change it to Any CPU so it will load on both architectures.
If you build it on a 32bit machine, it is likely that you just don't have the 64bit .Net framework installed.
In addition, the built-in Dev server is also 32bit, so you won't be able to run it there.

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

"The specified module could not be found" error when running C# ASP.NET web service referring C++ dll

I have C# ASP.NET web service project in visual studio 2005 which refers a C++ dll. But when I try to run the web service I get the following error which is shown in the web browser:
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.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +86
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +83
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath) +10
System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context) +43
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +180
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
However I refer the same dll for windows form application in the same solution and it is working fine. For this windows application to work I used Dependency Walker software to resolve few dependencies of the dll. But I can't figure out how to resolve this error when I try to run the web service. My operating system is Windows 7 Ultimate 64 bit
Can I know why I m getting this error and how to resolve this ?
thanks
My guess is your C++ dll is likely unmanaged code.
The C++ dll you're refering, it's compiled in 32bit or 64?
The windows app works because you're
launching the process.
The web app is running within
the web server's application pool
which is set to run in either 32 bit
or 64.
In IIS Manager, select Application
Pools. In the list of Application
Pools, select the application pool you
have configured for your web app. In the Actions
pane, select Advanced Settings under
Edit Application Pool. Expand the
General settings, set Enable 32-bit
Applications to True, and click OK.
In my case I am trying to deploy via clickonce a C# program that calls a managed C++ dll that calls an unmanaged dll. The error was that the reference or assembly [managed dll] or one of its prerequisites couldn't be loaded, and the second line said that it couldn't be found, even though I could see the dll in the application files in the deployed folder. The link below mentioned that the correct redistributable package might not be installed on the target machine, and this was the case. The ClickOnce Prerequisites popout menu allows to select, in my case, the Visual C++ "14" Runtime Libraries (x86). Upon installing the newly built application, the installer asks the user to download this software, and after that I could run the application on the target machine.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/2736bd39-56dc-46bb-8222-f8b1d0b93255/urgent-unable-to-load-dll-the-specified-module-could-not-be-found?forum=netfxbcl

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