Alon Amir
Alon Amir

Reputation: 5025

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.

Upvotes: 1

Views: 421

Answers (2)

Arve
Arve

Reputation: 7506

For .NET projects you have the COM tab in the "Add References" dialog. Add a reference to your COM object and it should just work.

If it works on a development machine, but not in production you just have to check all the usual suspects:

  • Is the COM object (and dependencies) registered on the production server.
  • Does the web server run in 64 bit? That will stop you from running 32 bit COM object in process.

Upvotes: 1

user1228
user1228

Reputation:

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.

Upvotes: 1

Related Questions