views:

329

answers:

1

I have a class library created in .NET 4.0 When I use the Enterprise Library Configuration tool to load this assembly, I get:

Error loading assembly: Could not load file or assembly. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I have tried the Configuraiton tool in both the Enterprise Application blocks 4.1 and 5.0 beta. Is .NET 4.0 not supported by the Configuration tool.

alt text

A: 

The problem is that the EntLibConfig.exe runs in .NET 2.0 by default while it tries loading an assembly that just can be loaded within a .NET 2.0 process. You could try to change the configuration of the EntLibConfig.exe to run in .NET 4.0 by changing the EntLibConfig.exe.config file.

No promises here, but try adding this to the EntLibConfig.exe.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <startup>
      <!-- Find out the exact version number and 
          put that in the version attribute. -->
      <requiredRuntime version="v4.0.0.0" />
   </startup>
   ...
</configuration>

Let me know if this worked out for you.

If you haven't read already, I'd recommend you to read this article about avoiding configuration pitfalls with incompatible copies of Enterprise Library. It's written by one of the developers of EntLib.

Steven
Yes, that worked! As always, thanks a lot for your insight.
Also, in some screenshots I've seen the Enterprise config tool is listed in the context menu within VS environment when you do a right click on the config file. I wonder how to get it listed on my machine.
With Visual Studio 2008 is was a matter of running the EntLib installer. It automatically installed itself as plugin. I think the installer does not support this for 2010. Perhaps you can manually register this, but I've got no idea how to do this. You can try asking here at SO.
Steven