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

1

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

asp.net
c++
web-services
dll
dependencies
asked on Stack Overflow Jul 5, 2010 by chathuradd

2 Answers

0

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.

answered on Stack Overflow Jul 5, 2010 by GenEric35
0

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

answered on Stack Overflow Aug 28, 2018 by premes

User contributions licensed under CC BY-SA 3.0