473,378 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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
Nov 15 '05 #1
13 1474
COM or nothing.

Tough.

"winthux" <wi*****@klub.chip.pl> wrote in message
news:bv**********@absinth.dialog.net.pl...
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

Nov 15 '05 #2
<.> wrote:
COM or nothing.

Tough.

Actually not quite true, you can achieve this through creative
roundtripping. (or you could use Delphi for .NET)

http://www.blong.com/Conferences/Bor...32AndDotNetInt
erop.htm

Also see the book "Inside Microsoft .NET IL assembler" by Serge Lidin

Rgds Tim Jarvis.

Nov 15 '05 #3
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.

"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
<.> wrote:
COM or nothing.

Tough.

Actually not quite true, you can achieve this through creative
roundtripping. (or you could use Delphi for .NET)

http://www.blong.com/Conferences/Bor...32AndDotNetInt
erop.htm

Also see the book "Inside Microsoft .NET IL assembler" by Serge Lidin

Rgds Tim Jarvis.

Nov 15 '05 #4

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)

Nov 15 '05 #5
Is this supported? 2.0 could this be removed in which case hes a.ssreamed.
"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...

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)

Nov 15 '05 #6
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
Nov 15 '05 #7
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.

"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #8
> 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.
Nov 15 '05 #9

"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
<.> wrote:
COM or nothing.

Tough.

Actually not quite true, you can achieve this through creative
roundtripping. (or you could use Delphi for .NET)


http://www.blong.com/Conferences/Bor...32AndDotNetInt
erop.htm
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>

Willy.


Nov 15 '05 #10
Tim,
see inline ***

Willy.

"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
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.


*** 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.
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

Nov 15 '05 #11
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.
Nov 15 '05 #12
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.

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 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.
Nov 15 '05 #13
Tim,
inline ****
Willy.
"Tim Jarvis" <tj*****@NoSpamForMe.com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
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 ;-)

Cheers Tim.

Nov 15 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: bart | last post by:
Hello, I'm so sorry, but i don't understand the concept of the .net environment yet. I made a simple program that retrieves the hostname and ipaddress of the local computer. But when i give...
1
by: Brian Henry | last post by:
How do you make a project template like how the add-in project is? I need to make my own custom template so I can create projects with predetermined sets of items and settings. thanks!
1
by: pnr | last post by:
I am makeing a system where every user have there ovn menu, they can chose between about 20 different sides they want in there menu. Eache side contains that menu, the user logs in with username...
7
by: Hal Vaughan | last post by:
I have a problem with port forwarding and I have been working on it for over 2 weeks with no luck. I have found C programs that almost work and Java programs that almost work, but nothing that...
8
by: Seeker | last post by:
Hello, In using Solaris Pro Compiler to compile Pro*C code. I am getting this error: make: Fatal error in reader: parser_proc_online.mk, line 26: Badly formed macro assignment Based on other...
4
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
5
by: P | last post by:
I was wondering what sort of changes I need to make in order to make an application to be DEP compatible with on Windows XP x64 version 2003. I have compiled an open source C application...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
1
by: rich_sposato | last post by:
I released version 2.0 of C++ Unit Test Library. You can download it from SourceForget.Net at http://sourceforge.net/projects/cppunittest/ .. I wrote this unit test library because other unit...
5
by: puneetsardana88 | last post by:
Hi I tried to make a library using code blocks. For which I went file->new->project->static library and name it as mylib and then i created a file mylib1.c and mylib1.h (with some sample functions...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.