views:

82

answers:

1

Hi,

PostSharp 2.0 includes a CLR host and implements IHostAssemblyStore::ProvideAssembly.

From managed code, I invoke:

Assembly.Load("logicnp.cryptolicensing, Version=3.0.0.0, Culture=neutral, 
               PublicKeyToken=4a3c0a4c668b48b4")

My implementation of IHostAssemblyStore::ProvideAssembly receives the following input for the first parameter pBindInfo:

0x002cd578 {
dwAppDomainId=1 
lpReferencedIdentity=0x03c123f8 "logicnp.cryptolicensing, version=3.0.0.0,  
                             culture=neutral, publickeytoken=4a3c0a4c668b48b4" 
lpPostPolicyIdentity=0x03c14620 "logicnp.cryptolicensing, version=3.0.0.0,   
    culture=neutral, publickeytoken=4a3c0a4c668b48b4, processorarchitecture=x86"
}

My implementation then returns the right stream. Note that the binding identity of that file is "logicnp.cryptolicensing, version=3.0.0.0, culture=neutral, publickeytoken=4a3c0a4c668b48b4".

When I return this file from ProvideAssembly, the CLR throws the following exception:

Could not load file or assembly 'logicnp.cryptolicensing, Version=3.0.0.0, 
Culture=neutral, PublicKeyToken=4a3c0a4c668b48b4' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly 
reference.  (Exception from HRESULT: 0x80131040)

So the assembly I returned does not match the post-policy reference, which is true, but this post-policy reference is incorrect.

I wonder if there is any workaround to this issue or if I am misunderstanding something.

This is an important issue for me and I have many users complaining on our support forum.

Any help would be highly appreciated.

Thank you.

-gael fraiteur

PS. Configuration: CLR 2.0 x86 or x64 (latest updates installed), Windows 7 x64.

I also posted this question on MSDN Forum at http://social.msdn.microsoft.com/Forums/en/clr/thread/93efa20f-5423-4d55-aa3d-dadcc462d999.

A: 

The question has been answered on http://social.msdn.microsoft.com/Forums/en/clr/thread/93efa20f-5423-4d55-aa3d-dadcc462d999.

Basically, it is a documentation bug:

Instead of returning ERROR_FILE_NOT_FOUND from IHostAssemblyStore::ProvideAssembly (as specified in documentation), the host implementation should return COR_E_FILENOTFOUND (defined in corerror.h).

Gael Fraiteur