You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public interface classIFoo
{
virtualboolDoWork(constchar type);
};
When I mock it:
varmocked= Mock.Of<IFoo>();
It throws the following exception:
System.TypeLoadException was unhandled by user code
HResult=-2146233054
Message=Signature of the body and declaration in a method implementation do not match. Type: 'Castle.Proxies.IFooProxy'. Assembly: 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source=mscorlib
TypeName=Castle.Proxies.IFooProxy
StackTrace:
at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.TypeBuilder.CreateType()
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.CreateType(TypeBuilder type)
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType()
at Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String typeName, Type proxyTargetType, Type[] interfaces, INamingScope namingScope)
at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.<>c__DisplayClass1.<GenerateCode>b__0(String n, INamingScope s)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory)
at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCode(Type proxyTargetType, Type[] interfaces, ProxyGenerationOptions options)
at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors)
at Moq.Proxy.CastleProxyFactory.CreateProxy(Type mockType, ICallInterceptor interceptor, Type[] interfaces, Object[] arguments)
at Moq.Mock`1.<InitializeInstance>b__2()
at Moq.PexProtector.Invoke(Action action)
at Moq.Mock`1.InitializeInstance()
at Moq.Mock`1.OnGetObject()
at Moq.Mock`1.get_Object()
at Moq.Mocks.<CreateMocks>d__0`1.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at lambda_method(Closure )
at System.Linq.EnumerableExecutor`1.Execute()
at System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.First[TSource](IQueryable`1 source)
at lambda_method(Closure )
at Moq.Linq.MockQueryable`1.Execute[TResult](Expression expression)
at System.Linq.Queryable.First[TSource](IQueryable`1 source)
at Moq.Mock.Of[T]()
at MoqTest.Class1.Test() in c:\users\mvdto_000\documents\visual studio 2015\Projects\MoqTest\MoqTest\Class1.cs:line 20
InnerException:
It occurs only with const modifier and only with char. It works fine without const as well as with another type (e.g. int).
The text was updated successfully, but these errors were encountered:
@mvdtom, thanks for the report. This is an issue with Castle DynamicProxy, so I have forwarded your report to the Castle Core project (see castleproject/Core#277) with some added details.
A fix for this has just been merged into Castle.Core (see castleproject/Core#278), so this issue will be resolved as soon as we update Moq to DynamicProxy >4.1.0.
This has been taken care of in Castle.Core, so there's nothing left to do here other than wait for the next release of that dependency. This is being tracked by #402.
There is an interface written in c++/cli:
When I mock it:
It throws the following exception:
It occurs only with
const
modifier and only withchar
. It works fine withoutconst
as well as with another type (e.g.int
).The text was updated successfully, but these errors were encountered: