tags:

views:

25

answers:

2

Hi,

I have an unmanged 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.

Please help.

+1  A: 

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.

Will
the code works when I run it in VS..., I don't think it has something to do with my code..., I aint doing anything recursive either :/
Alon Amir
I can't debug an app when it runs on the server..., What do you meen by check your properties?, what properties.?
Alon Amir
@alon so it works local but not on the server. You can actually debug remotely, as long as you can access the server from your development machine. Do some googling about visual studio remote debugging. Other than that, windbg and good luck. BTW, properties are `public Whatever Foo {get{return _foo;}}`
Will
+1  A: 

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.
Arve
I ran the app on VS2008 on the webserver and it was just fine.
Alon Amir
Everything is registered on the web-server
Alon Amir