views:

19

answers:

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

A: 

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.

GenEric35
the C++ dll reference is added as a project and it is compiled as 64 bit. i don't know even how to compile it in 64 bit. I m not quite familiar with this managed and unmanaged code. However it is mainly native C++ which has been used. Is that the reason for the issue ?All this time I have been trying to run it in Visual Studio Development server. Running in IIS seems to be much difficult task. When I tried using IIS as you have explained, now the application does not even start the web browser. Instead it gives a big error screen :(
chathuradd
I could be wrong too, it might not be the reason for the issue, but it's something to consider. The reference is not found, right click your reference and check the properties, it's Path, and also set Copy Local to true. If this unmanaged dll is yours and inside the same solution, it's can be simple to compile in 32bit, Build->Configuration Manager. Listed are the projects in your solution, projects from c# managed code have a platform of any CPU since they are compiled just in time(JIT) to fit the bit mode of the application, while unmanaged you pick a new platform win32 or x64. (continued)
GenEric35
You might read a little bit on Visual Studio Configuration Manager, to add the new win32 and x64 platform to the list of platforms. To host your web app in IIS, first check if IIS is fully installed on your win7, including all the sub features of IIS this version of IIS is able to host this. Typical steps are create a virtual directory, add an application pool; or see if you can simply use Visual Studio to configure IIS to run your web application right from it's current folder. Right click your web project, properties, there should be tab called web, Use Local IIS, Create Virtual Directory.
GenEric35
Referencing a C++ dll can be a bit of an advanced topic, reading the links above provided by Isalamon will help. Like I said earlier, maybe I went on a side track focusing on the C++ reference, if it dosen't solve, let's see if others have different input to help you solve it.
GenEric35