Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to call non-COM legacy dll from ASP.NET -OR- write COM wrapper in C#

Reply
Thread Tools

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

 
 
Chris Bordeman
Guest
Posts: n/a
 
      04-10-2008
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?


 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      04-10-2008
http://www.java2s.com/Code/CSharp/La...LFunctions.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"
<REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
wrote in message news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
 
 
 
Chris Bordeman
Guest
Posts: n/a
 
      04-10-2008
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>)


"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> http://www.java2s.com/Code/CSharp/La...LFunctions.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"
> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
> wrote in message news:(E-Mail Removed)...
>> 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?
>>

>
>



 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      04-10-2008
Add a direct reference (Browse, locate the COM dll, etc)

Jeff
"Chris Bordeman"
<REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
wrote in message news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
Chris Bordeman
Guest
Posts: n/a
 
      04-10-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Add a direct reference (Browse, locate the COM dll, etc)
>
> Jeff
> "Chris Bordeman"
> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
> wrote in message news:(E-Mail Removed)...
>> 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?
>>

>
>



 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      04-10-2008
Now YOU didn't read my message. You need to Browse for it...it might not
show in the list

Jeff
"Chris Bordeman"
<REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Add a direct reference (Browse, locate the COM dll, etc)
>>
>> Jeff
>> "Chris Bordeman"
>> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
>> wrote in message news:(E-Mail Removed)...
>>> 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?
>>>

>>
>>

>
>



 
Reply With Quote
 
Chris Bordeman
Guest
Posts: n/a
 
      04-11-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Now YOU didn't read my message. You need to Browse for it...it might not
> show in the list
>
> Jeff
> "Chris Bordeman"
> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
> wrote in message news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Add a direct reference (Browse, locate the COM dll, etc)
>>>
>>> Jeff
>>> "Chris Bordeman"
>>> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
>>> wrote in message news:(E-Mail Removed)...
>>>> 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?
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      04-11-2008
Does this help?

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


"Chris Bordeman"
<REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
wrote in message news:eph$(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Now YOU didn't read my message. You need to Browse for it...it might not
>> show in the list
>>
>> Jeff
>> "Chris Bordeman"
>> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
>> wrote in message news:(E-Mail Removed)...
>>> 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" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Add a direct reference (Browse, locate the COM dll, etc)
>>>>
>>>> Jeff
>>>> "Chris Bordeman"
>>>> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
>>>> wrote in message news:(E-Mail Removed)...
>>>>> 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?
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      04-11-2008
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"
<REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
wrote in message news:(E-Mail Removed)...
> 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>)
>
>
> "Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> http://www.java2s.com/Code/CSharp/La...LFunctions.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"
>> <REMOVE_DUPED_LETTERSccchhrriiiissbbooooorrddeemma (E-Mail Removed)>
>> wrote in message news:(E-Mail Removed)...
>>> 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?
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ASP.NET (c# code behind) will not load legacy C++ dll Andy Sutorius via DotNetMonster.com ASP .Net 6 01-18-2006 04:07 PM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Programmatically inserting controls into old legacy Response.Write style code Benjamin Joldersma ASP .Net Building Controls 0 05-13-2004 06:41 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments