How to make dll library in C# for C++ program

  • Thread starter Thread starter winthux
  • Start date Start date
W

winthux

The program is written in C++ and uses dll library. I want to write plugin
in C#, but inside library should be some functions ( ActionProc, etc.). How
to write it?

(Sorry about my english)

Thanks,
Winthux
 
Yes because modifying the assembly manifest is C# right?

To expose methods from an assembly you must make some changes to the
assembly manifest (found at the top of the IL file before the class
declarations). There will be references to other assemblies in the manifest
as well as general module information:



I do belive he said C# and not MSIL.
 
I do belive he said C# and not MSIL.

Seems to me that he just wanted to know how to do this. The methods
(business functions) would still remain C# it's only the assembly
manifest that has to be modfied slightly, in fact i am sure it would be
possible to write a utility app that does this

I don't see where you are coming from with this post, what's wrong with
giving a more complete answer to the question ? I looked at the post
and nowhere did he say, the solution must be C# only, IMO that would be
very narrow interpretation.

The answer I gave would fit his requirement i.e. a C# assembly with the
addional step of disassembing modifying and then reassembling, all with
tools that are provided with the framework.

Would you have the same problem if there were a 3rd party C# compiler
that allowed this option "out of the box" or would you then complain
that the solution didn't use the MS compiler ?


(by the way, although I mention how this can be done, I am *not* an
advocate of doing this, but it is a technique worth noting - hence the
post)
 
Is this supported? 2.0 could this be removed in which case hes
a.ssreamed.

It's part of the framework specification, the limitation is simply with
the C# compiler, not the framework.

The Delphi .NET compiler supports it out of the box, and it would not
surprise me if later versions of the C# compiler do as well. And
obviously the IL assembler supports it.

But again let me be clear I am not an advocate of this solution, my
personal preference for interoperation between win32 and .net is COM or
web services (or both), but it's always good to know all the solutions
that are available, so that you can make informed decisions that best
refelct your requirements.

Tim
 
I can see its uses if I have an application like netmon protocol parsers etc
that takes entry points from a flat DLL and has no COM plugin support.

I would hope they add this feature in later IDE builds. I would also like
to see .lib static linking of .net assemblies.

Inverse P/Invoke like P/Invoke and COM is necessary as a migration path.
 
I would hope they add this feature in later IDE builds. I would also
like to see .lib static linking of .net assemblies.

yep, me too.

Still, it's not overly hard to do the "hard way" it sounds much more
difficult than it actually is, that article link I posted shows how in
pretty simple steps. (the code is in Delphi, but should be pretty
simple to convert, delphi is closer in syntax to C# than VB is IMO)

Cheers Tim.
 
Tim,
see inline ***

Willy.

Tim Jarvis said:
It's part of the framework specification, the limitation is simply with
the C# compiler, not the framework.

The Delphi .NET compiler supports it out of the box, and it would not
surprise me if later versions of the C# compiler do as well. And
obviously the IL assembler supports it.

*** Again, according the article in the link you posted, this is not true,
you have to tweek the resultant IL created by Delphi .NET.

*** Another remark is, that only global methods(static in C#, shared in VB)
can be exported. While this can be used when calling some API style utility
functions, it can't be used as a general purpose solution in an OO
environment.
 
Willy Denoyette [MVP] wrote:

Not sure why you mention Delphi. Following is a quote from the
article (see URL)

<quote>

Clearly we will be focusing on the first area, since Delphi for .NET
does not support exporting .NET methods.

</quote>

Hi Willy,

With that quote I can certainly see why you came to that conclusion :-)
, at the time that Brian wrote the paper the Delphi (preview) compiler
didn't allow the export of .NET methods, but as a result of the
research that Brian (and others) did, the support was added. (I should
drop him an email to update the paper)

The shipping version (Released December 2003) of the Compiler does
actually now allow it.

Please don't get me wrong I am not here in these groups to promote
Delphi, even though I do work for Borland and love Delphi, I also Love
C#.

I only come here to get my C# questions answered (somtimes even answer
a question)

Cheers Tim.
 
Willy Denoyette [MVP] wrote:

*** Another remark is, that only global methods(static in C#, shared
in VB) can be exported. While this can be used when calling some API
style utility functions, it can't be used as a general purpose
solution in an OO environment.

I totally agree with you on this point, I just mentioned it for
completness sake, as I said, my option for interoperation would be COM
or Web Services (and when Indigo is real, probably just Web Services)

Cheers Tim.
 
Tim,
inline ****
Willy.
The shipping version (Released December 2003) of the Compiler does
actually now allow it.
*** Allways good to know :-)

Please don't get me wrong I am not here in these groups to promote
Delphi, even though I do work for Borland and love Delphi, I also Love
C#.

*** There's nothing wrong with a little promotion, after all (IMO), it's not
the language but the use of the Base Class Library which is fundamental to
..NET programming.

I only come here to get my C# questions answered (somtimes even answer
a question)

*** You're welcome ;-)
 
Back
Top