Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

A simple class library question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richard d - 20 Mar 2008 16:06 GMT
Well - at least I hope it is :-)

Having spent some time developing my c# application, using Visual
Studio 2005, I would now like to start re-factoring some of my code
into a class library so that I can use it in other applications I will
want to write and distribute (by which, BTW, I mean sell to a wide
audience).

Either I'm looking in the wrong book / help topic / whatever, or this
doesn't seem to be as easy as I would have liked.

I understand that I want to build a DLL, and that Visual Studio lets
me do that easily enough. I'm not sure how easy it will be to keep
both library and current application open at the same time so that I
can migrate code across - so I guess that's my first question.

Ideally, then, I should have some sort of distribution system for my
applications set up so that an app only uses the latest version of the
dll. In other words, if I distribute the DLL with app1 and app2, and
app2 has a more recent version of the DLL than app1, but app1 is
installed after app2, then the more recent DLL will not be over-
written. Is that when I need to stick the DLL in the GAC and start
looking at versioning?

Then there's the business of public/private key encoding, which
appears to me to be performed by a utility which presumably is getting
access to my company name from my PC? I mean, how does this tool (sn)
guarantee uniqeness? And should I bother with it.

Cheers

Richard
Jon Skeet [C# MVP] - 20 Mar 2008 17:07 GMT
<snip>

> I understand that I want to build a DLL, and that Visual Studio lets
> me do that easily enough. I'm not sure how easy it will be to keep
> both library and current application open at the same time so that I
> can migrate code across - so I guess that's my first question.

The easiest way is to have the class library project in the same
solution as the application.

> Ideally, then, I should have some sort of distribution system for my
> applications set up so that an app only uses the latest version of the
[quoted text clipped - 3 lines]
> written. Is that when I need to stick the DLL in the GAC and start
> looking at versioning?

Personally I'd avoid using the GAC for this as it complicates things.
So long as app1 and app2 are installed in different directories, there
shouldn't be any issues.

> Then there's the business of public/private key encoding, which
> appears to me to be performed by a utility which presumably is getting
> access to my company name from my PC? I mean, how does this tool (sn)
> guarantee uniqeness? And should I bother with it.

Strong naming isn't about getting access to your company name - but
unless you actually *need* strong naming, I'd avoid it personally.
Life is *easier* in an unsigned world, although obviously there are
downsides too.

Jon
richard d - 20 Mar 2008 19:07 GMT
> <snip>
>
[quoted text clipped - 29 lines]
>
> Jon

Thank you for your answer, once again :-)

Just on the business of the shared library between app1 and app2 - if
I install app2 after app1, how can I get app1 then to pick up the
updated library (now in app2's directory)?

Cheers

Richard
Jon Skeet [C# MVP] - 20 Mar 2008 20:05 GMT
<snip>

> Thank you for your answer, once again :-)
>
> Just on the business of the shared library between app1 and app2 - if
> I install app2 after app1, how can I get app1 then to pick up the
> updated library (now in app2's directory)?

You shouldn't - you may have some breaking changes, whether
deliberately or not. It's a much better idea to keep the library
effectively separate, IMO.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

richard d - 21 Mar 2008 16:14 GMT
> <snip>
>
[quoted text clipped - 11 lines]
> Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet  Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk

Thank you once again.

One last question (for now :-) )

Would you build both applications under the same solution? Or would
you have them as separate solutions but sharing the library project?

Cheers

Richard
Jon Skeet [C# MVP] - 21 Mar 2008 20:49 GMT
> Thank you once again.
>
> One last question (for now :-) )
>
> Would you build both applications under the same solution? Or would
> you have them as separate solutions but sharing the library project?

That depends on how big they are and how independent they are. A single
solution often makes life easier - but I wouldn't share the library
project, I'd refer to the DLL if you have the two applications in
separate solutions. Sharing a project between solutions has
occasionally been a pain in my experience.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Lasse Vågsæther Karlsen - 22 Mar 2008 11:03 GMT
>> <snip>
>>
[quoted text clipped - 20 lines]
>
> Richard

I can describe what I do personally.

I have my class library, a rather big one now, containing about 27
sub-projects with different categories of classes. These are in their
own right added to one big honking solution and added to Subversion.

In a project, where I need to use some of the class library projects,
but not all, I use Subversions externals support to make a solution
directory that have sub-directories containing "shared copies" of the
projects from the class library. This way I can easily modify both the
application project, as well as the individual class library projects.

Inside Subversion, only the solution folder + the application folder is
actually committed in one place, but the solution folder "knows" it
needs some sub-folders coming from a different place in source control,
and I can then easily grab a copy that can be compiled in total by itself.

With VisualSVN, addin for Visual Studio for Subversion support, this
works *almost* seamless. Only downside is that the class library
projects and the application project is not considered to be the same
"local working copy", so I can't do one commit and commit changes to
both my application project and the class library project in one go, but
that's it.

If, on the other hand, you're not using source control that allows for
such easy sharing of code, then I would probably keep the source control
solution in one place, open in one Visual Studio instance, and the
application project in another place, with references to the dlls, but I
would most likely make sure the application project has all it needs if
I just makes a copy of it to a new machine, so I would probably add a
directory where I would store binary copies of the class libraries, and
reference those, instead of having a relative reference from the
application project that reaches out outside the application project
folder and relies on explicit locations of the class library.

Not sure I made much sense here, but if not, and you want me to explain
something better, let me know.

Signature

Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.