Solved

DLL Library in C#

Posted on 2006-07-22
6
370 Views
Last Modified: 2010-04-16
How do I create a standard DLL library (not an assembly housed in a DLL) in C#, so that it can be used by unmanaged applications?
0
Comment
Question by:campinas
  • 3
  • 2
6 Comments
 
LVL 9

Assisted Solution

by:jonorossi
jonorossi earned 200 total points
ID: 17160687
That is not possible, C# code will always been managed code however you can call methods from unmanaged code. Take a look at these articles:

http://www.codeproject.com/csharp/ManagedCOM.asp
http://www.csharphelp.com/archives/archive190.html
0
 

Author Comment

by:campinas
ID: 17161029
Thanks! So one can access managed components from unmanaged applications...

Then I may need to create a dll based on the "class library" C#/vs.net project type.

But then, how do I call its functions from an unmanaged app?
0
 
LVL 5

Expert Comment

by:paulb1989
ID: 17161355
You will have to write your C# class library as a COM object as is shown in the links jonorossi wrote above. Then from your unmanaged application you can access your C# project as any other COM object.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:campinas
ID: 17161421
The problem is I don'y have access to the source code of the unmanaged app. It's just prewired so that it accepts dll shared libraries, not COM objects. What can I do?
0
 
LVL 5

Accepted Solution

by:
paulb1989 earned 300 total points
ID: 17161431
Well the only way I can think of is to write your C# class library as a COM object and then create a native DLL (not in C#) which the unmanaged app can load, and make your native dll call your C# COM object.

So you would have the unmanaged app, your managed C# COM object, and an unmanaged dll interfacing between them.
0
 

Author Comment

by:campinas
ID: 17161695
thanks all for helpful comments.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now