 |
 |
Nice Article
**Shadmehr**
|
|
|
|
 |
Great article ...could you update for .Net 4.0 since SHFusion.dll is deprecated?
|
|
|
|
|
 |
Jeremiah!
You really rock! excellent article, you taught me really wonderful stuff, I have been bugging with GAC since yesterday. It completely solved my issue, particularly in the way deleting the assemblies from Gloabl cache.
Cheers
Dayal
|
|
|
|
 |
In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR.
The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. There was no need in the previous two framework releases to split GAC. The problem of breaking older applications in Net Framework 4.0.
To avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.
In .NET Framework 4.0, the GAC went through a few changes. The concept of placing assemblies into a global directory began in CLR v1.1. In case of .NET Framework 1.1 (which had CLR v1.1) and .NET Framework 2.0 (which had CLR 2.0), the GAC was split into two, one for each CLR. This avoided the leaking of assemblies across CLR versions. For example, if both .NET 1.1 and .NET 2.0 shared the same GAC, then a .NET 1.1 application, loading an assembly from this shared GAC, could get .NET 2.0 assemblies, thereby breaking the .NET 1.1 application.
The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. As a result of this, there was no need in the previous two framework releases to split the GAC. The problem of breaking older (in this case, .NET 2.0) applications resurfaces in Net Framework 4.0 at which point CLR 4.0 released.Hence, to avoid interference issues between CLR 2.0 and CLR 4.0, the GAC is now split into private GACs for each runtime."
AE
|
|
|
|
 |
Thanks for the great stuff you posted here.
very useful stuff, but I still have to learn much more.
Shay berkovich
ITBiz
קייטרינג[^]
|
|
|
|
 |
Its a great stuff at one place.
I have few questions please answer
a)if 2 or more applications refrence the same dll then how the memory management is done?
b)how many copies of the dll loaded and in which address space?
|
|
|
|
 |
I have read lots about AssemblyBinding and how it locates assemblies etc. I have reda your article...
But still noone seems to mention a way simply to detect whether the assembly can be loaded, and then fallout gracefully (ie custom error message, or relevant error message such as <assembly name=""> cannot be found...
It is not always possible to install the assembly that is missing, or not applicable. For instance if I link to the Word.dll assembly, but the end user has not got word installed... then I want to be able to say "sorry you have not got word installed!" then exit.
But it always crashes with an exception (|File Not Found) which is great but it crashes before it gets to your code so that you can't actuially catch it.
Anyone got any answers?
Ben Glancy
Software Developer
|
|
|
|
|
 |
How to install multiple assembly using gacutil.exe
|
|
|
|
 |
Hi there
I hve recently started working with CRM 4.0 and I am trying to install the Moile Application for this so CRM can be accessed from mobile phones. I am getting an error message and through a lot of research have discovered the cause is that the Microsoft.Crm.WebServices.dll is not included in the assembly cache.
I have read that I need to register this dll to the GAC, but I am not that familiar with assemblies. Can someone please tell me how to do this?
Many thanks
Eve 
|
|
|
|
 |
Hi,
how about resding the above article???
Pst, pst: "Add an Assembly to the Assembly Cache".
Volker
|
|
|
|
 |
I want to register assembly while installing..
How can I do this??
|
|
|
|
 |
Hi,
Why should we go for GAC. If am installing any web app on my m/c then there will be all dll in my bin folder whats need of GAC at all.
If you are using GAC,then how application will know the certain assembly only has to used like there we can have multiple copies of same assembly with different version.
|
|
|
|
 |
In your situation, don't install in the GAC. Indeed, it is easier to be certain you have the correct version of dll if you are obtaining it from your bin folder. In fact, Microsoft recommends NOT installing in GAC unless the dll needs to be accessed by multiple applications.
I would say the main benefit of GAC is to provide a central place to search for compatible dlls. For example, I want to install some custom ASP.NET controls, and have them usable by another app (in this case, Expression Web).
|
|
|
|
 |
Fantastic article! Really cleared up a lot of things! Have you considered working for MSDN? Would make the lives of a lot of MS Developers a whole lot easier!
How about a follow up article for the .Net framework 2.0? Most of the stuff is the same, but any minor/major changes would become clearer...
|
|
|
|
 |
i made new versions of a shared assemblies. then by changing version numbers in the test clients app.config file i tried to use older version....but watever version i keep in old version and new version it always uses the latest version made...pls helppp
|
|
|
|
 |
You need to distribute a manifest file (xml file). It looks like: appname.exe.manifest
When your application loads, it checks for the manifest and loads the depends based on the specifications indicated within.
hope this helps.
Greg
|
|
|
|
 |
In my project i want to invoke a exe from web for this I have tried a lots of methods to overcome security.But the reason is, it is not working in all machines.So can you give this suggestion by codings.
Thanx in Advance.
C.Babu B.E.,
|
|
|
|
 |
I am a bit confused about referencing assemblies in the GAC. Maybe you could clarify a bit.
If I add my assembly into the GAC, how do I reference it? Do I reference the original Assembly DLL, or do I now have to reference it in relation to where it is within the GAC somehow?
I gave this a try. I applied a strong name to one of my assemblies and added it into the GAC. I then created an application to instantiate an object from my assembly. The application works fine as long as the assembly is in the same path as the application, but as soon as I move the application to a path where the assembly DLL is not located, it crashes with an exception that the assembly was not found. I thought that once the assembly is in the GAC, it should always be found. So I am not sure if I am referencing it wrong or if I am misunderstanding how the GAC works in relation to locating the whereabouts of the assembly DLL.
|
|
|
|
 |
To begin with ...let me clarify that you cant directly add a reference to an assembly from a GAC.
To do this you have to create another folder say "C:\MyAsemblies" and your dll to this folder.
and add a new registry key say "MyAssemblies" to registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetFramework\AssemblyFolders" and set its default data value as "C:\MyAssemblies"
Now your dll will be visible in "Add Reference" window in .Net Tab.
Naren
|
|
|
|
 |
I don't understand that part of the framework at all.
What's the point of adding my dll to the GAC if I STILL have to store the physical dll into a folder I choose and reference THAT FULL path when compiling an app that uses its reference?
Adding a dll to the GAC does not make things any different or better from referencing a private DLL - I still have to save the dll manually and reference its full path during compilation (csc,vbc in cmd).
My assumption was that the GAC would take the imported dll and store it in its cache and everybody would be able to reference it without specifying the path.
i.e. csc /r:MyDll.dll Source.cs, instead of
csc /r:c:\myfolder\MyDll.dll Source.cs
I would then delete my local dll since apps are not referencing it but instead use the cached copy in the GAC.
I hope I am making sense.
|
|
|
|
 |
The relevance of GAC will be more clear when you deploy your application/s and you have more than one application using same dll.
For e.g Say you create a class library called "Lib1.dll" and put this in GAC.
Create a project which will reference this "Lib1.dll".While you add the reference remember to set 'Copy local' property of the "Lib1.dll" as false.
Now create a setup containing the primary o/p of this project.Remember to exclude "Lib1.dll" from its dependencies.
Now deploy this project on a clients machine and put the "Lib1.dll" in Client's GAC "(which can be done using setup as well).
Now you will notice that your application folder would not contain "Lib1.dll" but still running fine.This is because it is refering the one which is inthe GAC
This entire excercise will look more relevant when you have many such projects/application deployed at clients machine and all of them having reference to "Lib1.dll" and you dont have to copy it in your application folder. Instead it will refer directly from GAC.
Also you can have more than one version of GAC and you can use <redirect> key in app configuration file to point to the other verison.
I hope this would help you understand the relevance of GAC.
|
|
|
|
 |
I have tried this but not working . can anybody give other way to do this.????????
|
|
|
|
 |
add a new registry key say "MyAssemblies" to registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NetFramework\AssemblyFolders" and set its default data value as "C:\MyAssemblies"
קייטרינג
|
|
|
|
 |
What will happen if I built app.exe using assembly.dll version 1.0.0.0 and I have in the GAC assembly.dll version 1.0.0.1? Will app.exe use the 1.0.0.1 version? What if I have both assembly.dll version 1.0.0.0 and 1.0.0.1 in the GAC? The same question for 1.0.1.0, 1.1.0.0 and 2.0.0.0. (I guess that the 1.0.0.1 and 1.0.1.0 will work and app.exe will use the latest version even if it was built with 1.0.0.0; and 1.1.0.0 and 2.0.0.0 will fail but is this true?)
|
|
|
|
 |
I tried out and found myself the answer. If the dll is in the GAC all four components of the version must match. If they dont match you get an error. If the dll is in the exe's folder the version numbers don't need to match.
|
|
|
|
 |
The load order is a bit more complicated but basically the CLR looks for an assembly in the GAC first, then it looks at the local bin directory. You are correct in the exact version match for GAC lookups however, things are different if a policy file is defined. Given a policy file,the policy may intercede when looking at the GAC and redirect to a newer version.
For example, you can use a policy file to redirect a request for an assembly to an upstream version so that a request for 1.0.0.0 could be satisfied by another newer version. Usually, based on how you use the version numbers you can establish a sane side-by-side execution model that matches the release model (i.e. if you want all 1.1.0.0 to 1.1.X.X where x.x is the most recent version you can define the policy to do this for you).
NOTE: To really understand the load process read http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhowruntimelocatesassemblies.asp[^]
-- modified at 16:56 Tuesday 19th December, 2006
Don Eddleman
Principal Enterprise Architect
Healthways
|
|
|
|
 |
"Note that when uninstalling, we use just the simple textual name of the assembly since for strong-named assemblies installed in the GAC, its simple textual name matches the DLL name."
Assemblies with same name but different key can be exist. So if your product happend to use the same assembly name as in a different product, when you uninstall your assemblies, and you just happend to use "gacutil /u MyAssembly" for this, their assembly will be uninstalled too!
The correct way to uninstall is by passing the key as well: "gacutil /u MyAssembly,PublicKeyToken=3369e15578a41c2c"
|
|
|
|
|
 |
How to copy an assembly file (e.g. System.dll ) form GAC (Global Assembly Cache) to other directory ( e.g. C:\\Temp)?
**Shadmehr**
|
|
|
|
 |
http://bloggingabout.net/blogs/jschreuder/archive/2006/08/09/13282.aspx
|
|
|
|
 |
I have created a assembly versioned 1.0.0.0 . i have copied it in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 dirctory and then add in GAC with strong name and i am able see it in VS .net add reference dialog box 's .NET tab .
now due to some fix release i have made a 1.1.0.0 version of same assembly and i have amde a new strong name file for that and pasted it in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 directory then it is replacing the old version file . now i have added it in GAC . IN GAC i can see both versions of assembly 1.0 and 1.1 . but i am not able to see both version in add reference dialog box of VS.NET . plz help me what have i done wrong ? in it ..
Anurag
|
|
|
|
 |
Absolutely superb article (highly informative, flawless English). Keep on writing.
|
|
|
|
 |
For example, I have third-party DLL, which can be installed by client everywhere in system (let's in GAC). I don't know version of the DLL, but I know DLL name (e.g. "MyLib.dll"). HOW I can _dynamicly_ load this DLL from code by string "MyLib.dll" (or by namespace)? I know about System.Reflection.Assembly.Load()/LoadFrom() but they needs exact info.
|
|
|
|
 |
I don't know what I have done. Somehow, I had lost the use of my soapsuds.exe. Actually, I don't know if it ever worked. I did some tests using it on my laptop, wherein soapsuds still works fine. However, on my home pc I get an error when trying to use soapsuds. I have xp service pack 2 on my home computer and not on the laptop. That is the only difference I can think of between the two computers. I must have tampered with something or deleted some files inadvertantly. I couldn't find any fix on this obscure problem on the net. I then instpected the gac to find that the soapsudscode.dll wasn't there on my home pc. Next, I uninstalled the currently installed .net framework and found the redistributable to reinstall it. Still no soapsudscode.dll. I then repaired my copy of visual studio .net. Still to no avail. I also went to the .net program repair utility which also didn't fix the program.
I really could use a fix about now. Any help would be greatly appreciated.
|
|
|
|
 |
Hi to all,
i have install an assembly in GAC but i can't unistall both i use from command line and Microsoft .NET Framework 1.1 Configuration tool. How can i do for solve this problem?
Thanks in advance
Enrico Zerilli
BizTalk Specialist
|
|
|
|
 |
You have to first assign a Strong Name by the SN utility(.snk file).then compile the Assembly file with the .snk file. then you can just drag and drop the assembly in GAC. To remove just delete the Assebly from the GAC.
|
|
|
|
 |
Can we have two assemblies in GAC with same major,minor,build and revision and ofcourse the name.
|
|
|
|
 |
You can add only one assembly in GAC with the same name,minor,major,build and revision propety, ofcourse you can add another one with different version
|
|
|
|
 |
You can assemblies in gac with same name and version, as long as they have differen keys
|
|
|
|
 |
Great article!
I'm curious though--the VS Add Reference dialog indicates a very different path for assemblies--they are not the GAC path.
How is it determining this path?
Thanks!
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
 |
GAC Path is different. Instead you have to copy your assembly in your .Net SDK v1.1.4322 folder or you can place your assembly in vs.net\common7\ide\publicassemblies folder. You will find your assembly in Add Reference Dialog box.
|
|
|
|
 |
Hi,
Thanks for the great article - it's helped me a great deal to get to the point where my apps are finding my shared component (on my dev machine). The only problem is deploying it so that the MSI actually puts the component in the GAC for me.
Maybe I'm missing a step but I assumed that when you build a deployment package the MSI would be clever enough to see that the component is public and therefore needs to go in the GAC. But this is not the case - the .dll is placed in the folder I want it to go to but not put into the GAC. I don't want to use another (manual) utility to put it into the GAC - I want it in an install package.
Can you tell me step-by-step how to do this?? I have looked everywhere for help but just keep going in circles - especially with Microsoft help that just tells you what the MSI should do but not HOW to make it do it!!
Please if you could help - its driving me crazy!!
Many thanks
Rob
Rob Snodgrass
|
|
|
|
|
 |
Who can explain me, what is an assembly?
best regards
astrit
|
|
|
|
 |
Refer to the definition provided by the MSDN documentation at http://msdn.microsoft.com/library/en-us/netstart/html/cpgloA.asp.
|
|
|
|
 |
Assembly is a unit of deployment, it can be a .dll or .exe file. it contails MSIL code,manifest. it is used for version control. While you compile your .net program, compile automatically generate an assemble (in a form of execuatable file .exe). you can deploy it in GAC (to be shared by more than one applications) called shared assembly or you can access it from the application folder called private assembly.
|
|
|
|
 |
I am using
main.exe and UserLibrary.dll with strong name key
in subfolder Components
this main.config file context
<?xml version="1.0"?>
<configuration>
<runtime>
<gcConcurrent enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<publisherPolicy apply="no" />
<probing privatePath="Components" />
But if UserLibrary.dll in GAC
main.exe load UserLibrary.dll from GAC
not from subfolder Components
How to setting program load assembly from subfolder ???
IS Possible ???
(Not delete from GAC)
test
|
|
|
|
 |
My main.config file
<?xml version="1.0"?>
<configuration>
<runtime>
<gcConcurrent enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<publisherPolicy apply="no" />
<probing privatePath="Components" />
</assemblyBinding>
</runtime>
</configuration>
test
|
|
|
|