Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# Class Files

Status
Not open for further replies.

markknowsley

Programmer
Aug 30, 2005
152
GB
This is more of a Visual Studio .NET question than C# specific, but there's no forum for that so this is the next best thing.

My question regards the update of class files. I have three seperate projects in Visual Studio .NET, and I want them to use two class files which contain tools I have written to do various jobs. So I created a folder called 'Class Files', put the files in here, and then attached them to each project by doing 'Add Existing Item'.

However, VS.NET takes a physical copy of the class files and puts them into each project folder. If I update the files in the 'Class Files' folder, the changes aren't made to the files in the project folders.

Is there a better way to share the class files so that I just have to update one file without having to remember to make the change three or more times?

Thanks in advance.
 
1. Create a new "Class Library" project, named "Common" for example
2. Add the class files to this project
3. Add a reference to "Common" to each project that needs to use those classes.
4. Save.
5. Build.
 
The projects that I'm writing are being compiled into DLL's and installed into the /bin folder on a web server; will I also need to compile the class library and place it in the /bin folder for my DLLs to be able to user the classes?

Or should I install the class library into the GAC?
 
The class library will compile to a .dll assembly. You need to put it in the /bin directory of the web server. GAC is not necessary.

Give it a try :p
 
If you need to share classes, the truly best way is to put them into their own assembly by creating a new class-library project.

However, it's also possible to move them to a "shared" folder in your source control working directory, then in visual studio, add them as an existing file. While this will work, it's not a solution I would recommend, as it requires a lot of discipline to managed these shared files, and you also need to over-communicate that you're doing this to the other members of your team. Don't forget that every time you hire someone new, you have to tell them about it, too. In the long run, it's just better to create a shared assembly rather than trying to share the files.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
No, the Class Library that B00gyeMan suggested worked a treat. The only problem I'm having is that sometimes I compile the Common DLL, followed by the project DLL and then install them but the project DLL falls over because it can't see the most up to date version of Common. It's something to work on.

I'm just one developer doing some very small projects. Managing this sort of thing on an Enterprise level project must be a real nightmare.
 
Managing this sort of thing on an Enterprise level project must be a real nightmare.

On really large projects there's just no way to manually manage the dependencies -- you either buy or write a tool to help you with it. The trick then is keeping it up to date, so you also write a tool to scan the .sln file & .csproj files looking for external dependencies.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top