Hi all,

I've found what appears to be a bug, exposed by the following code:

using Rhino.Mocks;

namespace TestMocks
{
    public class Foo
    {
        public virtual void Bar<T>(out T obj)
        {
            obj = default(T);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Foo foo = MockRepository.GeneratePartialMock<Foo>();
            object baz;
            foo.Bar(out baz); // throws BadImageFormatException
        }
    }
}
Causes exception:

Message: An attempt was made to load a program with an incorrect
format. (Exception from HRESULT: 0x8007000B)
Source: DynamicProxyGenAssembly2
Stack trace:
at
FooProxy49124d255d9247029eb160b7dd5ba379.InvocationBar_20.InvokeMethodOnTarget()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Rhino.Mocks.Impl.ReplayPartialMockState.DoMethodCall(IInvocation
invocation, MethodInfo method, Object[] args)
at Rhino.Mocks.Impl.ReplayMockState.MethodCall(IInvocation invocation,
MethodInfo method, Object[] args)
at Rhino.Mocks.MockRepository.MethodCall(IInvocation invocation,
Object proxy, MethodInfo method, Object[] args)
at Rhino.Mocks.Impl.RhinoInterceptor.Intercept(IInvocation
invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at FooProxy49124d255d9247029eb160b7dd5ba379.Bar[T](T& obj)
at TestMocks.Program.Main(String[] args) in C:\\data\\rhmbug\\TestMocks
\\TestMocks\\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I have tried the current release of Rhino Mocks and the nightly. My
environment is .NET 3.5 SP1 and it also  happens in the .NET 4 RC.

It only happens when Foo.Bar is virtual, has a generic out parameter
and is being partially mocked. In any other circumstances I've tried,
the problem doesn't occur.

Thanks,
Cameron

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to