开发者

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 confi开发者_如何转开发gure the IIS specialy.

Right now I'm getting a stackoverflow exception.


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜