This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

This error is given by the gacutil.exe if you try to register in GAC an assembly built with Framework 4.0 and you are using the gacutil.exe built for Framework 2.0.

The programs I develop don’t register any assembly in GAC when installed on an end user machine, except if there is the need to expose .Net function to a .COM application.

On the development machines instead, all the general purpouse libraries of my organization are installed in GAC, this is made to avoid versioning problems in projects that are using more than one solution, and are modified in different moments of the developer working time.

To register the libraries in GAC we use the gacutil.exe from a Post Build Event, the gacutil.exe has been conveniently copied in c:\windows to have it in the standard “PATH” environment variable.

Trying to register in GAC an assembly produced with framework 4.0 I’ve received the message put in the title and my assembly was not registered in the GAC.

The problem is due to the fact that the gacutil.exe I’m using was the version built for framework 2.0, which works correctly until framework 3.5. (since 2005). After some searches on the internet, where it is told that the utility ships with Visual Studio, I made a dir /s on my c:\ drive and found the new release of the utility here:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools

Copying the new utility and replacing the old one, my assemblies made with framework 4.0 are correctly registered in GAC. However, there is something different from before, the folder where the GAC was until framework 3.5,

c:\Windows\Assembly

is now replaced by:

C:\Windows\Microsoft.NET\assembly\GAC_MSIL

This is completely transparent for us Users, but probably it is the reason of the gacutil.exe upgrade we need to do.
The new version registers correctly the dlls made with older frameworks too.

Print | posted on venerdì 18 giugno 2010 15.19

Feedback

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by John at 30/09/2010 14.02
Gravatar Great post!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by A.K.Falk at 16/02/2011 15.24
Gravatar I attempted to register a .NET 4.0 assembly with the "old" gacutil and got the error message wich is the header of this post. I googled the error message and hit this post on top of the search - and it contained just the info I needed. Thumbs up :-)

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Eve at 17/03/2011 8.44
Gravatar I'm having a same problem in using gacutil considering that I only have an SDK for .net 2. Do I still need to install VS2010 just so I can have a gacutil for .net 4? I have no plans of buying a VS2010. I just really need to transfer some dll's to GAC. I need it make my program communicate with the others. Thanks in advance!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Tommy Turkijevic at 25/03/2011 16.02
Gravatar What to copy where ?, Do i copy only gacutil and reaplce it or is it the whole folder ?

Thank you in advance.
/TT

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Sabrina at 26/03/2011 15.32
Gravatar Usually I keep a copy of gacutil.exe and gacutil.exe.config on my c:\windows folder so that the PATH is automatically available to my batch commands in the Post Build Event of my projects. So you have to copy those 2 files on that folder or whatever folder you prefer, and you have to address the gacutil commands to that folder.
HTH
Sabrina

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Sabrina at 26/03/2011 15.35
Gravatar Gacutil.exe is a part of the Visual Studio SDK, if you use the .net framework 2.0 the old gacutil will do. Anyway, I think the SDK can be downloaded also without VS2010 installed or at last you can download the Express version that will be able to run together with the VS2005 or VS2008 you are using now.
HTH
Sabrina

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Mohamed at 26/04/2011 22.30
Gravatar you rock!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Rick McMullan at 10/05/2011 16.40
Gravatar Thanks you for posting this! I was having a problem with an Outlook 2007 AddIn which was very similar. Threw the same error and worked okay under .Net 3.5.

Most Exchange-based Outlook AddIns need to run caspol.exe afterwards so it will trust network shares. I used the CaspolSecurityPolicyCreator code sample to do this is a post-build custom event. The .Net framework version was hard coded:


private static string GetFrameworkFolder()
{
// Get the targeted Framework folder.
Version version = new Version(4, 0, 30319);
return GetRuntimeInstallationDirectory(version, true);
}

All of you who are using that should be aware when you are porting to .Net 4.0!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Prabin at 13/05/2011 7.35
Gravatar Great Post .. This helps me a lot. Thanks :)

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Kowbee at 09/06/2011 14.42
Gravatar Where do I have to copy the file to?
Can someone give me the exact location?

Thanks!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Sabrina at 10/06/2011 10.08
Gravatar If you read a few posts before yours, there is one post where I make an example of how I use the Gacutil.exe. You have to put it in a place from which the batch commands in your post build events can use it to register and unregister libraries to the gac of the machine.
If you want to use in production, you have to put the gacutil into your setup package as content copying them in the installation path and then call them from your program to register the dlls in GAC.

# Thanks a lot!

Left by Robo Shobo at 23/07/2011 17.27
Gravatar You've really saved me! THANKS!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by North Face Stroe at 31/08/2011 7.21
Gravatar my sentiments and I will instantly snatch your rss feed to be updated on any upcoming content you may publish,I am really fan of your site! North Face Kids Denali Jackets

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Davit at 07/12/2011 12.08
Gravatar Thank you very much!!!

# re: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Left by Kiran at 24/01/2012 20.42
Gravatar Saved MY DAY !!!!! Great Post

Your comment:





 
Please add 3 and 6 and type the answer here:

Copyright © Sabrina C.

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski