Welcome to MSDN Blogs Sign in | Join | Help

0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

So, you have (or have to write) ASP.Net page or webservice, which should call native C++. Generally, it’s just extra work, but sometimes there is no other way, at least, no easier way.

Overall that’s fairly easy – use COM or P/Invoce, that’s it. However, sometimes you do so, and it does not work no matter what. A pretty common case is HRESULT code 0x800736B1 with a full message like "Unable to load DLL exception. This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem." Very often case. And very puzzling. And not very well documented.

So now a big hint: that usually does not mean that your DLL is not found (although that’s possible), it usually means that your DLL depends on other DLLs that are missing. It usually happens when you develop on one machine, and deploy/run on another, especially if it has a different version of Windows or misses Visual Studio. Just check that everything needs is on the machine or link statically (although that will increase the size of your DLL).

P.S. Oh, I was just told that this is not the only thing that could go wrong... Sorry if I was not clear enough. What I wrote above, is something happening easily and likely, while overall list of what can go wrong is HUGE:

- permissions on DLL(s)
- code security
- wrong .config file
- wrong version of .Net
- P/Invoke problems/signature matches/encoding/preserving-not preserving signature...
- actual file location
- not being in a right place or Path if DLL is specified without a full path
- more..

Published Wednesday, June 07, 2006 8:37 PM by EldarM
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

How does one link statically?
-gary
Friday, September 15, 2006 1:48 PM by ghuckabone

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

Statically? Native .lib files will not link with managed assemblies. If you mean DLLImport, yes, there is such a problem because ASP.NET code is compiled into some other place, and nobody wants to put the binaries into System32. One option is to add a special directory to path -- to the end of the list -- and put there you native DLLs. I used another way -- preloading native DLLs with LoadLibrary() -- this works too. As long as the DLL already loaded, the system does not look for it on the disk. But in this case, you need to know the path to your DLL in ASP.Net page to load it.

Actually, I should write about it with examples. Thanks for the idea!
Monday, September 18, 2006 7:21 PM by EldarM

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

We create a C++ managed DLL using desktop with VS2005 with SP1. when i try to use the DLL in the desktop without SP1(service pack 1). I am ending with "The application is "the application has failed to start because the application confiquration is incorrect. etc.. (Exception from HRESULT: 0x800736B1)"].

".

Is there any way to solve the problem. whats the reason for this problem

Friday, January 12, 2007 12:55 AM by Senthil Balu

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

I have exactly the same problem, does anyone have a solution? --I build a DLL that is sent to thousands of users. They do not have Visual Studio, this all worked fine until SP1.

Thursday, January 18, 2007 7:55 PM by Tony Antonucci

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

See http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en

These are the required runtime components to run apps develpoed with VS2005.  You either need to include this in your distribution, or use VC++6.

Monday, January 29, 2007 9:47 PM by Paul

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

The available VC+ redist only installs the .42 version of the C Runtime files.  This does not resolve the issue when you compile using VS SP1 which references the .762 version of the C Runtime files.  We tried everything from including the folders in our install directory to updating the path and system32, but nothing worked.  Even Depends showed that everything was available, but the web service would not run on the target machine.

We resolved this issue by compiling using a machine without VS SP1 installed.  Not ideal, of course, but allows us to keep going.

Tuesday, March 06, 2007 3:51 PM by Terrence

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

This is also true for windows services and winforms apps developed in .NET, not just web apps/services. I've been struggling with this issue for two days now. I 've got my service running on my local XP Pro machine, but deploying to Server 2003 is rough. Not to mention it's the 64-bit edition.

Friday, April 06, 2007 12:22 PM by Brent

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

I took my Win32 dll and in the section where it asks you how to link to MFC, I put in "Use Standard Windows Libraries" and everything works fine now.  The DLL is 10x larger but disk space a dime a GB so who cares right?

Friday, April 27, 2007 9:27 AM by Erik Miller

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

Hi there,

THanks for the insightful article. I am trying to get a very old application set up in Vista and I am getting the "was loaded but the call to DLLRegisterServer failed with error code 0x80040154" error. After googleing for a bit I found our article. What might be a way for me to find out the dependencies of a dll file for an application that I can't install?

Any assistance would be great.

Sherif a t sherifmansour dot com

Sunday, May 13, 2007 7:56 AM by Sherif Mansour

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

SysInternals FileMon was pretty good at that. Also there is a tool in Visual Studio for that, but it did not worked real time, rather trying to model the execution.

Thursday, June 14, 2007 5:14 PM by EldarM

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

I was having the same error when distributing an .exe I built with VS 2005.  I found it was solved by including the redist files found in C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86

If I distributed the folders:

\Microsoft.V80.CRT and \Microsoft.V80.MFC

and placed them in the same directory as the application, the configuration error went away.  Hope this helps.

Tuesday, June 26, 2007 1:14 PM by BrockG

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

Hello friends

I am facing lotof problems , registering dlls and ocx in vista, even after setting the protective mode off. I use a .Net application that invokes a dll on the client machine that further registers certain controls after transferring them from server.

I have checked rights in TYPELIB and CLSID both , through my code, and there is ALLACCESS.Still the registerserver fails to run

Thursday, June 28, 2007 2:44 AM by nitin

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

BrockG:

With .exe it's a natural problem. You can replace DLL with static library in the project C++ / Code Generation options, and then you won't have to copy DLLs from Visual Studio. Although your files will grow for about 500K in size.

Nitin:

It's really hard to say what's wrong when symtoms are just " a lot of problems". .Net app may run under a different identity, DLL may have bugs in the way ot registers the coponents, comonents may not match what this DLL tries to register or have their own bugs, if the do part of the self-reg themselves...

Tuesday, July 24, 2007 2:19 PM by EldarM

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

Hi,

I was facing the same problem yesterday and we resolved it.  Basically we have a C# program that includes a C++ project.  Like others have mentioned above, when we build the solution it compiles the C++ project using .62.  Sure enough, our clients only have .42.  

Microsoft recently published service pack for the C++ redistributable package.  It is a 2.6MB download.  When we installed in our clients machine, everything worked perfectly.

Here is the link to the download on Microsoft's website: http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&displaylang=en

Also, I came to this solution via:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1240807&SiteID=1

Good luck,

Ryan

Thursday, August 30, 2007 1:42 PM by Ryan Taylor

# Resolution to (Exception from HRESULT: 0×800736B1) « TechnicalArchitectureWorx

# BadImageFormatException or FileLoadException

I have a problem deploying a managed DLL to a new machine.  I am running .NET Visual Studio 2005 (professional ed.).

When in debug mode, I get a FileLoadException, and in release mode I get a BadImageFormatException.  The dll actually does load but instantly unloads itself.  I believe that the assembly is loading but cannot instantiate any of the objects that are contained in the dll and the exceptions above are thrown depending on Debug/release mode.  I can step to the code right up until I try to instantiate an object.  When I step in, I get the load/unload trace to the output window followed by the exception trace.  

Any help would be greatly appreciated.  I tried uninst/reinst, and copied dlls from other machines, etc.  and have spent nearly a week on this issue.  Thanks,  Chris

Thursday, April 24, 2008 2:39 PM by Chris Pozsgai

# re: 0x800736B1: Calling C++ code from ASP.Net (from .aspx pages or .asmx webservices)

in most of the cases u need following folders:

The folders you need for that are

Microsoft.VC80.CRT

Microsoft.VC80.DebugCRT

Microsoft.VC80.DebugMFC

Microsoft.VC80.MFC

Microsoft.VC80.MFCLOC

Microsoft.VC80.OPENMP

as well u sud use depends.exe(C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin) and check the system log for the required file missing.

but if ur using release mode then leave the debug folders of Microsoft.VC80 .

i solved my problem but its a royal pain in ass :-)

Saturday, June 21, 2008 7:58 AM by shravan

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker