views:

39

answers:

2

Hi, I'm trying to use MEF2 Preview in my .NET4 project. MEF2 Preview version is "System.ComponentModel.Composition.Codeplex" file with "System.ComponentModel.Composition, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35" assembly name.

So it only differs by revision number from the version in .NET/GAC (which is 4.0.0.0).

I checked that codeplex version is placed side by side with my exe-module. And also checked that assembly reference from exe-module is correct (to 4.0.0.1 not to 4.0.0.0).

But as I run my app CLR loads version from GAC (4.0.0.0).

I tried to add this in .config file:

<runtime>
    <assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">
        <dependentAassembly>
            <assemblyIdentity name="System.ComponentModel.Composition"
                              publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="4.0.0.0" newVersion="4.0.0.1"/>
        </dependentAassembly>
    </assemblyBinding>
</runtime>

It doesn't help. CLR is still loading GAC version of assembly (4.0.0.0).

How to make CLR load 4.0.0.1 version which resides the executable?

A: 

When resolving a reference to an assembly named System.ComponentModel.Composition, the CLR will not automatically look for a file named System.ComponentModel.Composition.Codeplex.dll.

Have you tried to rename the local copy of the file to System.ComponentModel.Composition.dll?

Mattias S
When I try to add a reference to System.ComponentModel.Composition.dll then instead of adding ref to my local assembly a reference to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.ComponentModel.Composition.dll is created.So local assembly is just ignored.
Shrike
How are you adding the reference? If you use Visual Studio, are you browsing to the local assembly instead of just selecting it from the .NET tab in the Add Reference dialog?
Mattias S
Actually it doesn't matter how I'm adding refenrece. Resulting assembly has a reference to 4.0.0.1 version which is placed in the same folder. But CLR won't use it.
Shrike
+1  A: 

The cause of config was ignored is the typo in XML.

should be:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

instead of:

<assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">
Shrike