Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile two .cs files into single DLL?

Tags:

c#

Say I have foo.cs and bar.cs. if I create two seperate projects for each source file and compile them to two DLLs, I have no problem in importing and using them in other projects.

What should I do if I want an output of single DLL?(with keeping separate source files) Can a DLL file have two namespaces? if not, How can I place contents of foo and bar into single namespace? (I can edit them)

like image 962
thkang Avatar asked Jan 31 '26 18:01

thkang


2 Answers

if I create two seperate projects

Create one project with both files in it to produce one DLL as output. The namespaces can be anything you'd like, though convention suggests that classes within a project share a common root namespace.

like image 192
David Avatar answered Feb 02 '26 07:02

David


You only have to add both files to the same Project.

Can a DLL file have two namespaces?

Yes. And conversely one namespace can be used in multiple DLLs.

like image 45
Henk Holterman Avatar answered Feb 02 '26 06:02

Henk Holterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!