views:

365

answers:

1

I am trying to introduce Strong Signing in my project assemblies.

My project output is persisted in XML and a type is mentioned (before signing) as:

typestr="XYZ.PQR, MyWidget, Version=1.0.2406.20198, Culture=neutral, PublicKeyToken=null"

After all the assemblies are signed with public-key with token, 622edca63ee1770c. I have introduced <assemblyBinding> block in my app.config file as follows:

 <assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="MyWidget" publicKeyToken="622edca63ee1770c" culture="neutral"/>
    <bindingRedirect oldVersion="1.0.2406.20198" newVersion="0.1.27.10695"/>
  </dependentAssembly>
 </assemblyBinding>

I am still getting Error:

Could not load file or assembly 'EPGWidget, Version=1.0.2406.20198, Culture=neutral, PublicKeyToken=622edca63ee1770c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

When a code piece like:

Type type = Type.GetType(typestr);

following is executed. However, it works for:

typestr="XYZ.PQR, MyWidget"
+1  A: 

If you are serializing as xml, why is there type information in it? One of the objectives of xml is to remove type metadata from the serialization. Is this an array or something? There may be better ways to serialize this data.

Assembly redirects do not, AFAIK, work with string-based reflection; if the qualified name doesn't match, it doesn't match. The last example doesn't specify the signing details, which allows it to accept any.

Personally, I'd try to fix the issue of having type information in the xml - it is probably an easier, and more appropriate, battle to fight.

Marc Gravell