Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reusable classes
Message
De
02/08/2010 16:15:28
 
 
À
02/08/2010 15:40:32
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
Divers
Thread ID:
01474897
Message ID:
01474913
Vues:
42
>>>>>Hi again,
>>>>>
>>>>>Well, another newbie question.
>>>>>
>>>>>I have a vb file containing a class definition. I what to be able to use the same vb file is different solutions. But when I reference an existing vb file in a location outside the project, VS makes a copy of the original and passes it in the current project folder. Hence, I now of two copies of the file. Now when I modify one of the copies, I have make sure I update all the other copies.
>>>>>
>>>>>Is there a way to have a central repository of shared files that all project share?
>>>>
>>>>Can you build your generic classes into dll and reference this dll in your projects?
>>>
>>>I thought about do that, but felt the classes were small enough that they didn't require becoming DLLs.
>>
>>Naomi's right - put them in a separate project.
>>Having lots of little DLL's in .NET is no big deal. Takes a while to start thinking that way but remember these aren't the same animal as COM DLLs.
>
>I am beginning to see this. Coming from the world of COM, it is abit of a learning curve to stop think as if the .Net DLL class are COM-like.
>
>I built the common class into it's ouw DLL. Then added a reference from another application to the common DLL. When I build the application, i receive a whole lot of error refering "Microsoft.Common.Targets". I sure it has something to do with the reference i just added. But what?
>
>Do I need to copy the DLL to the working project folder. I rather mantain a single copy that other project only reference. Having to copy the DLLs around is as defeative as having the copy the VB file.

I don't know why you're getting the Microsoft.Common.Target errors - that sounds as if the solution or project build is getting screwed up - maybe you should start with a new solution. Anyway when you want to access the common classes you have two options :

(a) add the *project* containing the common classes to the solution and, in the project where you want to use those classes add a reference to the project (i.e from the projects tab of the 'Add reference' window)
or
(b) add a reference to the comm DLL itself (from the 'Browse' tab point to the actual DLL)

Use the first option if you might want to make changes to the common classes during development, use the latter it not (reduces clutter). In either case when you build the application the relevant DLL will automatically be copied into the bin folder of the main application so you should never need to 'manually' copy the DLLs.

This works even when you have deeper references. E.g if ProjectA references ProjectB which references ProjectC then when you build the ProjectC DLL will be copied into the ProjectA bin folder.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform