Question

I have an interface definded like this:

public interface IDatabase{ void Get<TTypeToFetch> ();}

and when I try to do: Mockery mockery = new Mockery(); IDatabase db = mockery.NewMock<IDatabase>(); I get the following error:

System.TypeLoadException: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match

What is wrong? (I am using Visual Studio 2008 with nmock2) Please could everyone give me an answer, I have to finish this soon. Thanks, Luisa

Was it helpful?

Solution

I think this may be a problem with NMock, possibly even a bug. The type IDatabase is not generic, so when you invoke Get<T>, different Ts could be used at runtime. But when NMock is generating the mock, it doesn't appear to understand that this is the case, and kablammo -- each method signature is different, depending on the type parameter supplied.

Try doing this instead:

public interface IDatabase<T> {
  void Get<T>();
}

Also, shouldn't the type of Get be T, not void?

OTHER TIPS

I had the same exception with my own interface. When i change interface to be public everything runs ok.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top