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

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

am 10.04.2008 23:33:21 von 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?

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

am 11.04.2008 00:01:13 von NoSpamMgbworld

http://www.java2s.com/Code/CSharp/Language-Basics/CallingNat iveDLLFunctions.htm

--
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"

wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
> 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?
>

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

am 11.04.2008 00:14:25 von Chris Bordeman

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 )


"Cowboy (Gregory A. Beamer)" wrote in
message news:eabYkZ1mIHA.5260@TK2MSFTNGP03.phx.gbl...
> http://www.java2s.com/Code/CSharp/Language-Basics/CallingNat iveDLLFunctions.htm
>
> --
> 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"
>
> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>> 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?
>>
>
>

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

am 11.04.2008 00:53:36 von Jeff Dillon

Add a direct reference (Browse, locate the COM dll, etc)

Jeff
"Chris Bordeman"

wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
> 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?
>

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

am 11.04.2008 01:00:48 von Chris Bordeman

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.


"Jeff Dillon" wrote in message
news:elA2121mIHA.748@TK2MSFTNGP04.phx.gbl...
> Add a direct reference (Browse, locate the COM dll, etc)
>
> Jeff
> "Chris Bordeman"
>
> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>> 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?
>>
>
>

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

am 11.04.2008 01:28:15 von Jeff Dillon

Now YOU didn't read my message. You need to Browse for it...it might not
show in the list

Jeff
"Chris Bordeman"

wrote in message news:umlRO71mIHA.1212@TK2MSFTNGP05.phx.gbl...
> 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.
>
>
> "Jeff Dillon" wrote in message
> news:elA2121mIHA.748@TK2MSFTNGP04.phx.gbl...
>> Add a direct reference (Browse, locate the COM dll, etc)
>>
>> Jeff
>> "Chris Bordeman"
>>
>> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>>> 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?
>>>
>>
>>
>
>

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

am 11.04.2008 02:01:28 von 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.

"Jeff Dillon" wrote in message
news:Opu7MK2mIHA.2328@TK2MSFTNGP03.phx.gbl...
> Now YOU didn't read my message. You need to Browse for it...it might not
> show in the list
>
> Jeff
> "Chris Bordeman"
>
> wrote in message news:umlRO71mIHA.1212@TK2MSFTNGP05.phx.gbl...
>> 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.
>>
>>
>> "Jeff Dillon" wrote in message
>> news:elA2121mIHA.748@TK2MSFTNGP04.phx.gbl...
>>> Add a direct reference (Browse, locate the COM dll, etc)
>>>
>>> Jeff
>>> "Chris Bordeman"
>>>
>>> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>>>> 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?
>>>>
>>>
>>>
>>
>>
>
>

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

am 11.04.2008 02:13:07 von Jeff Dillon

Does this help?

http://support.microsoft.com/kb/306158


"Chris Bordeman"

wrote in message news:eph$Md2mIHA.5944@TK2MSFTNGP03.phx.gbl...
>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.
>
> "Jeff Dillon" wrote in message
> news:Opu7MK2mIHA.2328@TK2MSFTNGP03.phx.gbl...
>> Now YOU didn't read my message. You need to Browse for it...it might not
>> show in the list
>>
>> Jeff
>> "Chris Bordeman"
>>
>> wrote in message news:umlRO71mIHA.1212@TK2MSFTNGP05.phx.gbl...
>>> 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.
>>>
>>>
>>> "Jeff Dillon" wrote in message
>>> news:elA2121mIHA.748@TK2MSFTNGP04.phx.gbl...
>>>> Add a direct reference (Browse, locate the COM dll, etc)
>>>>
>>>> Jeff
>>>> "Chris Bordeman"
>>>>
>>>> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>>>>> 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?
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

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

am 11.04.2008 03:37:09 von NoSpamMgbworld

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"

wrote in message news:ubzOPh1mIHA.4536@TK2MSFTNGP06.phx.gbl...
> 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 )
>
>
> "Cowboy (Gregory A. Beamer)" wrote in
> message news:eabYkZ1mIHA.5260@TK2MSFTNGP03.phx.gbl...
>> http://www.java2s.com/Code/CSharp/Language-Basics/CallingNat iveDLLFunctions.htm
>>
>> --
>> 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"
>>
>> wrote in message news:u1qlFK1mIHA.1184@TK2MSFTNGP04.phx.gbl...
>>> 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?
>>>
>>
>>
>
>