How to use my DLL writen by Visual C++ in ASP.NET?

Dear Experts:

I have a toolkit that is DLL writen in Visual C++.

Now I want to write web application in ASP.NET and want to invocate the functions in DLL.

I did some research and didn't find too much information on how to code ASP.NET using DLL.

Could anybody give me help, give me some links or tutorials?

Your help is highly appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have a few choices.  If it is a COM dll, you can use it directly from .NET.  Otherwise, you can write a managed C++ wrapper around the dll to expose the functionality in .NET form or you can use the PInvoke mechanism to call directly into the C++ dll from .NET.  Do you have an idea which of these options seems preferable?  If you don't have a COM dll, which seems to be the case from your brief question, then you would be looking at one of the other two options.  A managed wrapper is cleaner but may be more work depending on how much functionality is exposed by the dll.

The two non-COM options are described here:

What do you think?  A few more details of your dll will be helpful in figuring out the easiest path.
southmountainAuthor Commented:
Dear Experts:

I forgot to tell you that I have full source code for this DLL.
Do I have other options such as recompile it in Visual C++.NET?

If it is good choice I might considering migrating to Visual C++.NET.
Recompiling does not really help you.  Your options are still the same as I outlined previously.  Converting to managed C++ helps, but that is a lot more than merely recompiling.  Have a look at the managed extensions in VC++ .NET -  This would also be used to write a managed wrapper for the dll.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

southmountainAuthor Commented:
Thanks a lot for your comments.

I am not sure if it is a COM DLL. based on my document, I should copy this DLL to
my \WINNT\SYSTEM32 directory.

Based on your suggestion and I do write a managed C++ wrapper, how can I use it in ASP.NET?
Any more links for demo? my final goal is to write a web application.


Take a look here
The DLL is implemented in C# - but it's just the same - when you write the wrapper for your unmanaged DLL - you can call it like in this demo.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You use the managed wrapper from ASP.NET just like you use any other assembly in .NET.  You add a reference to the managed dll to your web app project and then you have access to the components in the library.  Just right click on "References" in the Solution Explorer, select the ".NET" tab and then browse for the wrapper library file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.