Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Bordeman - 10 Apr 2008 22:33 GMT
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?
Cowboy (Gregory A. Beamer) - 10 Apr 2008 23:01 GMT
http://www.java2s.com/Code/CSharp/Language-Basics/CallingNativeDLLFunctions.htm

Signature

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!

*************************************************
> Using VS2008.
>
[quoted text clipped - 13 lines]
>
> Is there a better way?  Or a way to avoid COM altogether?
Chris Bordeman - 10 Apr 2008 23:14 GMT
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>)

> http://www.java2s.com/Code/CSharp/Language-Basics/CallingNativeDLLFunctions.htm
>
[quoted text clipped - 18 lines]
>>
>> Is there a better way?  Or a way to avoid COM altogether?
Cowboy (Gregory A. Beamer) - 11 Apr 2008 02:37 GMT
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?

Signature

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!

*************************************************
> 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.
[quoted text clipped - 27 lines]
>>>
>>> Is there a better way?  Or a way to avoid COM altogether?
Jeff Dillon - 10 Apr 2008 23:53 GMT
Add a direct reference (Browse, locate the COM dll, etc)

Jeff
> Using VS2008.
>
[quoted text clipped - 13 lines]
>
> Is there a better way?  Or a way to avoid COM altogether?
Chris Bordeman - 11 Apr 2008 00:00 GMT
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.

> Add a direct reference (Browse, locate the COM dll, etc)
>
[quoted text clipped - 17 lines]
>>
>> Is there a better way?  Or a way to avoid COM altogether?
Jeff Dillon - 11 Apr 2008 00:28 GMT
Now YOU didn't read my message. You need to Browse for it...it might not
show in the list

Jeff
> 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
[quoted text clipped - 21 lines]
>>>
>>> Is there a better way?  Or a way to avoid COM altogether?
Chris Bordeman - 11 Apr 2008 01:01 GMT
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.

> Now YOU didn't read my message. You need to Browse for it...it might not
> show in the list
[quoted text clipped - 25 lines]
>>>>
>>>> Is there a better way?  Or a way to avoid COM altogether?
Jeff Dillon - 11 Apr 2008 01:13 GMT
Does this help?

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

>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
[quoted text clipped - 33 lines]
>>>>>
>>>>> Is there a better way?  Or a way to avoid COM altogether?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.