Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2004-11-27
Medium Priority
Last Modified: 2013-11-25
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!
Question by:southmountain
  • 3
  • 2
LVL 19

Assisted Solution

drichards earned 1600 total points
ID: 12688665
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp.

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

Author Comment

ID: 12688776
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.
LVL 19

Expert Comment

ID: 12688856
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 - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconMCOverview.asp.  This would also be used to write a managed wrapper for the dll.
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.


Author Comment

ID: 12692456
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.



Accepted Solution

Svetlin_Panayotov earned 400 total points
ID: 12693960
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.

LVL 19

Expert Comment

ID: 12697496
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.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question