Friday, May 4, 2012

AxUtilLib.dll Issue with .NET 4

I ran into the following issue, which is now reported and recognized as an official bug by Microsoft.

When you use the AxUtilLib.dll assembly from a .NET 4 project, you can manage models from code. However, the DLL file is built against .NET 2.0 runtime. This poses no problem as those assemblies can be run in the .NET 4.0 runtime. However, when you export a model using this library in a 4.0 runtime, the exported model will be a.NET 4.0 assembly instead of a 2.0 assembly. When you then try to import this model using the powershell cmdlets or the axutil command line utility, you receive the following error message:

ERROR: The model file [filename] has an invalid format.

When you try to view the manifest of the model file, you get the following error message:

ERROR: Exception has been thrown by the target of an invocation.

When you open the axmodel file using ILSpy (remember the axmodel files are actual assemblies), you will notice that the model is a .NET 4.0 assembly, whereas a "good" model is .NET 2.0:




You will see the same behavior if you use the 2012 PowerShell cmdlets from PowerShell 3.0 (currently in beta). There is currently no fix for this, the only workaround is to use the command line utilities. Note that all other features work perfectly, including importing the model.

2 comments:

  1. Palle Agermark found a way to "fix" the exported models so they can be imported.

    http://palleagermark.blogspot.com/2013/01/axutillibdll-issue-with-net-4.html

    ReplyDelete
    Replies
    1. Hi Joris,
      how about fixing the link so its clickable.
      Happy New Year

      When are we going to get a beer.

      I'm thirsty.

      Delete