• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

DLL Library in C#

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
campinas
Asked:
campinas
  • 3
  • 2
2 Solutions
 
jonorossiCommented:
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
 
campinasAuthor Commented:
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
 
paulb1989Commented:
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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
campinasAuthor Commented:
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
 
paulb1989Commented:
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
 
campinasAuthor Commented:
thanks all for helpful comments.
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now