views:

47

answers:

2

Hi,

A part of big project is a payment system, that I would like to reuse. I want to merge all the class files of this payment system into DLLs so that add them as a reference in all the other projects. The present payment system is also using namespaces from the DLLs of a commercial application (nsoftware-paypal n few others). I tried csc to compile the individual files into DLLs but couldnt make it work. I also tried the ILMerge but this doesnt seem to work either.

CSC

As the .cs files uses the namespaces from the DLLs of nsoftware-Paypal, I included DLL files along with .cs in csc command. it gives me an error saying "...nsoftware.InPayPal.dll is a binary file instead of a text file". When I try to compile without the paypal DLLs it throws an error saying 'The type or namespace named nsoftware is missing'.

ILMerge does not allow the .cs files either(as its not an assembly of course).

All I need to do is to generate the one(or more) DLLs for this whole system so that I can use it in other projects.

Possible?

+1  A: 

you need to compile your .cs files using csc, then use ILMerge to combine the 3rd party assemblies with your generated assembly.

fyi there is an open source gui for ILMerge that can make things a little easier (at least at first).

http://sourceforge.net/projects/gilma/

In regards to your compilation issues you might want to check out this tutorial

in order to compile your code with a dll do something like this

csc /out:out.exe /r:third_party_dll.dll program.cs
luke
Yeah but there is a dependency problem if i try to compile all my .cs files using csc.
Hna0002
can you post the compiler error? this sounds like a different problem...
luke
I re-wrote the whole description again. Would really appreciate any help.
Hna0002
Awesome! U r THE MAN! thanks dude. It works. Let me see if I m able to access everything out it. ;) I was including third party dlls along with .cs and not as /r Thanks!
Hna0002
A: 

You need to use dllImport:

Take a look at this Example-Code:

http://www.adp-gmbh.ch/csharp/call_dll.html

Or this example:

http://www.codeguru.com/csharp/csharp/cs_data/article.php/c4217

If you need to pass structures:

http://msdn.microsoft.com/en-us/library/awbckfbz.aspx

And finaly the documentation for dllImport:

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx

Quonux
Thanks Quonux. Will check it out too.
Hna0002