I'm kinda new to c# and I'm trying to figure out a good solution for keeping common code somewhere that is used by several projects.
First I tried keeping it in a .cs file and add it to the projects that needs the code, but this COPIES the file meaning if I do any changes to the common code it will not be reflected in the various projects using this code.
Then I tried creating a class library instead and reference the DLL within the projects using the code. First of all I can't get this to work even though I am following the tutorials, Even when I reference the DLL I still cannot use it somehow, but even if this worked it still needs an extra DLL to be bundled with my app for some common code and that is not what I want.
Is there any way to keep common code that is REFERENCED without needing to ship a DLL w
The best solution is to have a common library that you reference in each of your projects. However you say you don't want to do that as it requires bundling additional dlls, is that really that big a issue? You also mention that you can't get that to work, post the details of errors etc and we will be able to help.
Another option, assuming you are using Visual Studio is to link the common file into your project rather than add it. This will keep the common file in its current location and not move it into your project directory.
To do this, go to the add existing file dialog but on the 'Add' button click the down arrow and select 'Link' instead.
As mentioned above using a common library is the best solution so if bundling this is a unsurmountable issue you could look into using ilmerge. This will merge all your dlls/exes into a single file that you can then deploy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With