tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate
MIT License
1.07k stars 75 forks source link

System.BadImageFormatException when using #44

Open binick opened 5 years ago

binick commented 5 years ago

Hi @tonerdo,

I'm having this exception

System.BadImageFormatException: 
An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)

The Shim is created with

Shim shimExecutor = Shim.Replace(() => 
    Is.A<QueryExecutor>().ExecuteAsync<T>(Is.A<string>(), Is.A<object>()))
    .With(delegate (QueryExecutor @this, string rawQuery, object parameters) 
    {
        return default(Task<IEnumerable<T>>);
    });

And I use context like this

IEnumerable<BaseReadModel> results = null;
PoseContext.Isolate(() =>
{
    results = executor.Execute<BaseReadModel>("lorem_ipsum");
}, shimExecutor);

I obtain exception when invoke Isolate.

The target framework is netcoreapp2.2 and I have installed version 2.2.102 on my machine, the version of Pose is 1.2.1.