开发者

Custom Common Library Classes in Visual Studio .NET

I wrote some classes that I use with many different projects. For example, I use Library.Controls.FlatButton.cs almost in every project. The problem is when I add this as an "existing item"; the class gets created/copied in my soultion folder everytime. And each time I edit/update the contents of that class, I have to update all the Library.Controls.FlatButton.cs files in every project folder.

I need to be able to edit a single source of FlatButton class and when I compile/build a project (that uses the class file) gets updated to the 开发者_如何学Pythonnew version of that class. Question 1: Is there a way to do this?

I know that I can gather all these classes in a library project (Library.Controls) and add it to each application solution as a dependency. Question 2: Is this the only way to work from a single source of common library files? And if I do; will all the classes in the Library.Controls namespace get compiled with every application, even if I've only used this FlatButton class in the project?

Hope this is clear for you.. thanks


I'd rather go with the approach of the shared library and add them as references to your client project.

If you don't want to do this. You could add the file as "Link". In Add existing item, select Add as Link instead.


Yes, a class library is the way to go and yes, since the whole class library will be referenced from your applications, all the classes will be available to it.

However, the fact that all the classes are available is not a bad thing, since they're in a separate class library it won't make your applications harder to understand (since the amount of code in those applications will stay the same), it might just be that you use up a little bit more hard drive space, though if you really worry about that you could put the class library in the GAC so that all apps reference the same copy of the library, though you'd better research this first to make sure that it's suitable for you.


Alternative way is to add FlatButton.cs file "As Link":

Custom Common Library Classes in Visual Studio .NET

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜