How to call non-COM legacy dll from ASP.NET -OR- write COM wrapper in C#

  • Thread starter Thread starter Chris Bordeman
  • Start date Start date
C

Chris Bordeman

Using VS2008.

Have an old straight C style dll, need to call it from ASP.NET. This
normally works easily using DllImport but ASP.NET apparently doesn't let you
call C dlls directly.

So I heard you can call COM dlls by just adding a reference. So I created a
C# class library with a single class that wraps and calls my C dll through
DllImport. I checked the 'Make COM Visibile' option and compiled. Used
regasm.exe to register the dll w/ COM, which reported success.

But I do 'add reference' on the ASP.NET app and the object is not to be
found on the COM list.

Isn't it supposed to show up?

Is there a better way? Or a way to avoid COM altogether?
 
OK I though I was really clear I *know* how to do basic native DLL calls.
ASP.NET doesn't allow DllImport and can only call .Net code directly.
THAT'S the problem.

I appreciate your response, but please read the question in it's entirety
before answering.

(I knew someone would do this <g>)
 
As I said, I tried to create one and then registered it using regasm.exe
(which supposedly succeeded) but for whatever reason now I don't see jack on
the COM list on the 'Add Reference' window.
 
Now YOU didn't read my message. You need to Browse for it...it might not
show in the list

Jeff
"Chris Bordeman"
 
I read that, but remember this is a .Net DLL with COM interfaces so loading
it by file just gets you a .Net reference. If it's gonna be seen by VS as
COM, it needs to be loaded via the COM list.

I've abandoned the COM route, looking for a a way to do this via remoting.

Thanks for your help.
 
Let me see if I have it right.

DLL in question is C.
You need to call it from ASP.NET.

If so the article is correct. You may have to wrap the DLL in a .NET
library, but it should work. WIth ASP.NET it should also be able to be
called from a ASP.NET web application instead of a ASP.NET web site. If it
does not work, wrap it.

I see no reason to wrap in .NET and then create a COM callable wrapper and
then call that. It creates something twice removed instead of something once
removed.

Am I still missing something?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Chris Bordeman"
 
Back
Top