Exporting functions in C#

  • Thread starter Thread starter Alexander Filatov
  • Start date Start date
A

Alexander Filatov

I need implementing Windows Cluster Resource DLL, that requires me creating
DLL exporting several functions. How it can be done in C#?

Thanks,
Alexander
 
You can create a DLL that implements an interface such as
IWEExtendContextMenu or IWEExtendPropertySheet and access it as a COM object
but you cannot use a C# DLL as you would a C++ DLL.

Implement your interfaces and register the DLL for COM interop in the
project build properties.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Hi Alexander,

Based on my understanding, you want to create a managed dll which exports
function to unmanaged code.
I think you can create a managed dll and create a COM wrapper for it. The
article below tells you how to do COM wrapper:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconcustomizingcomcallablewrappers.asp

The article below shows how to: "Export Managed Code as Unmanaged"
http://www.c-sharpcorner.com/Code/2003/Aug/ExportManagedCodeasUnmanaged.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi, Jeffrey!

As far as I know, COM dlls exports several predefined functions such as
DllRegisterServer, DllCanUnload etc. How can I export function with other
name (clustering API requires me exporting Start function)? Or... may be I
miss your thought?

The second link solves exact problem, but it is too awkward developing
application is such a way :(. Do you know, is this problem will be addressed
in next C# version?

Thanks a lot,
Alexander.
 
You can't build Cluster resource dll's using C#, native C++ is your only
option. You should even consider (yet) using any of the managed languages
for this kind of system level programming, the CLR overhead is too large for
things like device drivers, cluster resources ...., unless you don't mind a
workingset foot-print of ~8MB.

Willy.

Alexander Filatov said:
Hi, Jeffrey!

As far as I know, COM dlls exports several predefined functions such as
DllRegisterServer, DllCanUnload etc. How can I export function with other
name (clustering API requires me exporting Start function)? Or... may be I
miss your thought?

The second link solves exact problem, but it is too awkward developing
application is such a way :(. Do you know, is this problem will be addressed
in next C# version?

Thanks a lot,
Alexander.


"Jeffrey Tan[MSFT]" said:
Hi Alexander,

Based on my understanding, you want to create a managed dll which exports
function to unmanaged code.
I think you can create a managed dll and create a COM wrapper for it. The
article below tells you how to do COM wrapper:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconcustomizingcomcallablewrappers.asp

The article below shows how to: "Export Managed Code as Unmanaged"
http://www.c-sharpcorner.com/Code/2003/Aug/ExportManagedCodeasUnmanaged.asp
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top