Search

Friday, May 7, 2010

CRM 4.0 & .NET 4.0

For those that have had a chance to play with Visual Studio 2010 RC and .NET 4.0, you may have considered the possibility of writing CRM 4.0 extensions with this new framework. Unfortunately, this is not to be.

So what’s the problem exactly? The big jump is that Microsoft .NET 4.0 actually ships with a new version of the Common Language Runtime (CLR). It’s a bit confusing, but .NET 3.0 and .NET 3.5 actually used the .NET 2.0 CLR. This is because .NET 3.0 and 3.5 were really just a set of extensions to the framework and did not require an actual new runtime. This means that ASP.NET 2.x to 3.5 all used the same .NET 2.0 runtime! As such, Microsoft CRM 4.0 has no problem working with extensions that use the .NET 2.0 CLR, and takes advantage of framework extensions found in .NET 3.0 and 3.5.


So whether you run an in process plug-in or an asynchronous one, if you try to write a plug-in that uses the .NET 4.0 CLR you will get an error that looks something like this:

Microsoft.Crm.CrmException: Assembly cannot be loaded from C:\Program Files\Microsoft Dynamics CRM Server\server\bin\assembly\testing.dll. ---> System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft Dynamics CRM Server\server\bin\assembly\testing.dll' or one of its dependencies.



This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
 
For web pages/custom pages,
In theory, if you could get the CRM web site to run under ASP.NET 4.0, this would get around this error. However I am sure plenty of other things would break and this doesn’t help with plug-ins hosted by the Outlook client or the Asynchronous Service.
 
If you want to use .NET 4.0 with CRM 4.0, you are not entirely out of luck. As long as it runs in its own process space, either on the client (like a Silverlight 4.0 control) or on another web site (like an IFRAME or a pop-up dialog from a CRM form), things should work.
 
The good news of course is that Microsoft CRM 5.0 will be written take full advantage of .NET 4.0, WF 4.0 and more.

No comments:

Post a Comment