Click to See Complete Forum and Search --> : Public Shared Assembly please help
sans_tosh
December 10th, 2002, 04:17 AM
Hi All,
I have written as assembly in C#(Class) i have compiled this with strong name and have assigned it to GAC using gacutil.
I have checked the presence of the assembly in the WINNT/Assembly folder.
The problem is that i am not able to call this assembly from a client program.
I do not know how to create an object of this assembly. i tried with NEW operator but this Assembly is not listed in the pulldown menu which comes soon after we type NEW.
Can anybody please tell me how this can be done.
Thanks,
santosh
MartinL
December 10th, 2002, 05:55 AM
Did you add the reference to your assembly in the project where you want to use it?
sans_tosh
December 10th, 2002, 08:34 AM
Actually to avoid adding separate references for projects, we put the assembly in the GAC right(ie public shared).
if i add reference of the assembly to my project it becomes privately shared assembly.
MartinL
December 10th, 2002, 09:00 AM
No...
Global Assembly Cache is just a repository for shared assemblies... You must add reference to your project if you want to use any assembly. Otherwise, your code doesn't know anything about the classes exposed by that assembly. Or do you think that clr loads all assemblies installed in gac??? Would be stupid, wouldn't be?
I didn't hear anythink about privately shared assembly. What do you suppose that the privately shared assembly is???
Assembly can be just private or shared!
To make assembly private you have to put it in the same directore as exe file. Sure you can direct clr to look into the other directories if you specify <codeBase> element in config. file.
When you install assembly into the global assembly cache it automaticaly becomes a shared assembly.
Each application using some assembly have to load it. Reference in the project is the way, how you can specify which assemblies are used by your application. You need to add reference to System.Windows.Forms.dll if you want to use windows forms, needn't you? (sure, application wizard does it instead of you). So, why any other assembly should be the exception???
It has nothing to do with making the assemblies private or public!
Martin
Arild Fines
December 10th, 2002, 09:13 AM
Another issue is that you cannot add a reference to assemblies residing in the GAC directly. You need to reference a copy that is somewhere else than the GAC. Of course, at runtime the assembly in the GAC will be used.
Bottom line: For most purposes, the GAC is more trouble than it's worth.
sans_tosh
December 10th, 2002, 09:20 AM
Hi Martin,
Thanks for the info, i was in sure mis understanding.
it will be great if you can please tell how do i add reference of my assembly which is in GAC into my client project.
Thanks,
santosh
MartinL
December 10th, 2002, 10:55 AM
There is a References item in your Solution Explorer window in Visual Studio.NET. If you right-click on that item you can select Add Reference menu...
Martin
sans_tosh
December 10th, 2002, 11:39 PM
Then what is the use of shared assembly over private assembly ??
santosh
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.