[2.0] Best way to use common code between solutions?
What I want to do:
I have common code for utilities I will use in different programs. I want to store in one place, so that when code is improved (performance/remove bugs) all programs will be updated.
What I do now:
Common code is in a project. I make new programs as solutions, each with its own project code and also the common project code. Common code is compiled as a DLL which I reference/call from the main project, which is compiled as an exe.
Problem:
The common code is compiled as a DLL which I must distribute separately. Also, DLL can be called by other programs not written by me, using my cool utilities!
Solution?
What I want to do is to compile all the code in the solution to a single exe so the DLL is encapsulated and the distribution is a single exe. Seems VS can't do this from IDE. I think can do from command line - but that scares me!
Any way to compile together as exe from IDE? Or is there a better way to store 'common' code for various solutions/projects and stil gat a single exe at the end?
Thanks!
BG ;)
Re: [2.0] Best way to use common code between solutions?
You can actually rename a .exe to a .dll and reference it. Am I barking the wrong tree?
Re: [2.0] Best way to use common code between solutions?
There are ways to have a DLL and still prevent rogue applications from calling your class library.
Anyways if you want it in an EXE, you'll have to copy your code over into the same project as your EXEs, so that the entire thing gets compiled together.
Re: [2.0] Best way to use common code between solutions?
So there is no way to have a common code base that is used in different EXEs and gets updated automatically? If the code base changes then the new code has to be copied into EVERY project that uses it?
I find that very hard to believe. If that's true, then it looks like a major design defect. Surely there must be a way?
Re: [2.0] Best way to use common code between solutions?
That isn't what you asked for. You wanted to prevent users from using your classes, rather than allowing for automatic updates. Which one is it?
You can have a common code base, you can place your class libraries in the GAC, which other applications reference. Updates become easier too, you only replace those DLLs.
Re: [2.0] Best way to use common code between solutions?
Quote:
Originally Posted by mendhak
That isn't what you asked for.
..err, yes I did.
Quote:
Originally Posted by batgurl
I have common code for utilities I will use in different programs. I want to store in one place, so that when code is improved (performance/remove bugs) all programs will be updated..
Do you know the answer please?
Re: [2.0] Best way to use common code between solutions?
You must create your class libraries and strong name them first (sn.exe) and then use gacutil.exe to install them into the gac.
Re: [2.0] Best way to use common code between solutions?
Quote:
Originally Posted by batgurl dadadadadadada... BAT GIRL...
..err, yes I did.
Quote:
Originally Posted by batgurl
Any way to compile together as exe from IDE? Or is there a better way to store 'common' code for various solutions/projects and stil gat a single exe at the end?
Isn't that what you said?
Re: [2.0] Best way to use common code between solutions?
Well at least I've only got two eyes ;)
I'll try the GAC route - but it isn't quite what I was looking for.
I hoped for something like the good old VB6 days when you could include the same .bas file in several projects and jsut compile it in.
Thanks anyway.
Re: [2.0] Best way to use common code between solutions?
Hmm... fine, go by the GAC route. But can you describe the structure of the class library you want to share? What does it contain, what does it do? I doubt it'll help, but it might bring up a few other ideas...
Re: [2.0] Best way to use common code between solutions?
Quote:
Originally Posted by mendhak
Hmm... fine, go by the GAC route. But can you describe the structure of the class library you want to share? What does it contain, what does it do? I doubt it'll help, but it might bring up a few other ideas...
Ok. Let me set it out in detail:
I have a number of C# projects. Each of them should compile to a single exe.
There are some common elements that exist in all of these projects. For simplicity let's say there is one class that is used in all procedures and the code for that class is identical in all procedures.
I would like to keep the code for that class in one place, so that if it is updated, then all projects using it are also updated.
At the moment I have a fiel holding the code in every project and any updates have to be pasted into each project.
Under VB6 this was a trivial task. A file used in the project did not have to go into or under the folder containing the project. It could go anywhere - so two projects could share the same source code file.
I can't seem to get that to work under C# and I can't find an easy alternative.
Re: [2.0] Best way to use common code between solutions?
I used to be a VB6 programmer but am not completely sure what you're talking about. Because when it came to the compiled EXEs, how'd they know about the BAS files?
Anyways, with .NET, a lot of the paradigm changes. Remember, .NET isn't an upgrade to VS 6's "framework", it's a do-over. New rules, new problems. Therefore, GAC. :)
Re: [2.0] Best way to use common code between solutions?
I think batgurl means that the source code itself is shared by several projects. The only time any other app is updated is at build-time. You'd have to still redist all your apps every time the code is updated.
This is easy to do in .Net. When including the file that you want to share just use the "Add as Link" dropdown on the OK button. Its in the "Add existing item" dialog.