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..