Prism 4.5 and Unity 3.0

Topics: Prism v4 - WPF 4
May 10, 2013 at 10:20 AM
Anyone know how to use Prism (UnityExtension) 4.5 together with Unity 3.0(1304 which is the newly and only official release of Unity 3.0) ?
May 10, 2013 at 6:09 PM
Hi,

We downloaded both Prism for NET 4.5 and Unity 3.0 (1304) from the NuGet Package Restore. We tried to build the solution but it seems that Prism for NET 4.5 is targeted to Unity 3.0.1204.0, and the one that comes from NuGet, opposite to what its description says, it is signed as version 3.0.0.0 instead of 3.0.1304.0. Therefore, the build fails as Microsoft.Practices.Prism.UnityExtensions expects a higher version of Unity.

If you think this is a bug, feel free to open a new issue on the Issue Tracker in order for this to be considered on future releases.

Regards,

Federico Martinez
http://blogs.southworks.net/fmartinez
May 10, 2013 at 6:38 PM
Thanks, I will enter an issue.

Your observation is exactly same as mine except mine demands 3.0.1208.0.

Any fast workaround possible ? E.g. manipulation by ILDASM or similar ?
Developer
May 13, 2013 at 6:43 PM
Hi,

Based on my understanding, the Prism for .NET 4.5 assemblies are simply the Prism 4.1 projects targeting the .NET 4.5 framework and compiled against the updated versions of the ServiceLocator and Unity assemblies. Hence, a possible workaround could be to re-compile these Prism assemblies using Prism 4.1 as the base. Basically, you will need to:

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini
May 14, 2013 at 7:37 PM
Here is some ILDASM magic that worked for me:

http://stackoverflow.com/questions/16313287/error-with-unity-framework-in-net-wpf
1)"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\ildasm.exe" Microsoft.Practices.Prism.UnityExtensions.dll /out:Microsoft.Practices.Prism.UnityExtensions.il

2) Edit the Microsoft.Practices.Prism.UnityExtensions.il Line 21 to: ".ver 3:0:1208:0"->".ver 3:0:0:0" 3) save the .il file 4)"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe" Microsoft.Practices.Prism.UnityExtensions.il /dll /out:Microsoft.Practices.Prism.UnityExtensions.dll

Use the new .dll which has a reference to the version 3.0.0 and not 3.0.1208..

Hope it help ;)

Update: Probably you will also need to do a new sign on the new assembly:

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\ildasm.exe" Microsoft.Practices.Prism.UnityExtensions.dll /out:.\Signed\Microsoft.Practices.Prism.UnityExtensions.il

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe" .\Signed\ Microsoft.Practices.Prism.UnityExtensions.il /dll /key="C:\MyPublicPrivateKeyFile.snk" /output=.\Signed\ Microsoft.Practices.Prism.UnityExtensions.dll
May 15, 2013 at 6:04 PM
Thank you

I will try to work with MEF instead of Unity (after all it is now part of .Net framework).
Anyway I hope that Prism or Unity (don't know which one is wrong actually) will be matched soon.