Search code examples
asp.net-3.5

How can I call an unmanaged COM object within ASP.Net 3.5


I have an unmanaged COM object, and I would like to call it from ASP.NET 3.5.

Can I just call it like in C# or do I have to write something special in the web.config, or configure the IIS specialy.

Right now I'm getting a stackoverflow exception.


Solution

  • You can't just call a com object from managed code. You have to P/Invoke it. Check out pinvoke.net for how to p/invoke most of the windows API. There is also a tool for generating p/invoke code called the p/invoke interop assistant.

    As to why you're getting the overflow, its probably unrelated to any com calls. You're probably doing something else wrong. Check your properties, its one of the most common places you'll end up with a SO. Also, check your call stack at the point of the overflow, as it will tell you what method(s) is/are causing the issue.