System.TypeLoadException

102 views
Skip to first unread message

Ceri Lewis

unread,
Jun 11, 2008, 6:50:38 AM6/11/08
to Rhino.Mocks
Using Rhino Mocks 3.4

I have the following in a test method:
// Setup the mock objects
MockRepository mocks = new MockRepository();
IDeliveryPeriodConverterFactory
deliveryPeriodConverterFactory =
mocks.CreateMock<IDeliveryPeriodConverterFactory>();
*** IRangeExtractor rangeExtractor =
mocks.CreateMock<IRangeExtractor>();
IDataBlockExtractor dataBlockExtractor =
mocks.CreateMock<IDataBlockExtractor>();

When executing the line with *** I get the following:
System.TypeLoadException: Method 'ExtractRanges' in type
'IRangeExtractorProxyb07f490417024a5fb04a8dc0a2cbaa1d' from assembly
'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=a621a9e7e5c32e69' does not have an implementation..

The IRangeExtractor interface is defined as:
/// <summary>
/// Interface for extracting ranges from a data array.
/// </summary>
public interface IRangeExtractor
{
/// <summary>
/// Extract data ranges from the specified array. Return
/// any warnings in the list of strings.
/// </summary>
/// <param name="data">Array of <b>Object</b>s to extract the
ranges from</param>
/// <param name="dataRanges">List to store the data ranges in</
param>
/// <param name="dateRanges">List to store the date ranges in</
param>
/// <param name="warnings">List to hold any warning messages</
param>
void ExtractRanges(
Object[,] data,
IList<IDataRange> dataRanges,
IList<IDateRange> dateRanges,
IList<String> warnings);
}

IDataRange & IDateRange just have a few getter properties on them.

Any ideas what the probelm could be?

Thanks

Stack trace:
at System.Reflection.Emit.TypeBuilder._TermCreateClass(Int32
handle, Module module)
at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.TypeBuilder.CreateType()
at
Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType()
at
Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCode(Type
proxyTargetType, Type[] interfaces, ProxyGenerationOptions options)
at
Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type
theInterface, Type[] interfaces, ProxyGenerationOptions options)
at
Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type
theInterface, Type[] interfaces, ProxyGenerationOptions options)
at
Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type
theInterface, Type[] interfaces, ProxyGenerationOptions options,
IInterceptor[] interceptors)
at
Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type
theInterface, Type[] interfaces, IInterceptor[] interceptors)
at Rhino.Mocks.MockRepository.MockInterface(CreateMockState
mockStateFactory, Type type, Type[] extras)
at Rhino.Mocks.MockRepository.CreateMockObject(Type type,
CreateMockState factory, Type[] extras, Object[]
argumentsForConstructor)
at Rhino.Mocks.MockRepository.CreateMock[T](Object[]
argumentsForConstructor)

Ayende Rahien

unread,
Jun 11, 2008, 6:54:37 AM6/11/08
to Rhino...@googlegroups.com
Multi dimensional arrays are not supported. There is a CLR bug that prevent this.
You RemotingMock instead, that should work

Ceri Lewis

unread,
Jun 11, 2008, 7:02:41 AM6/11/08
to Rhino.Mocks
Thanks for the quick response.

So something like?
IRangeExtractor rangeExtractor =
mocks.CreateMockWithRemoting<IRangeExtractor>();

Ayende Rahien

unread,
Jun 11, 2008, 7:13:47 AM6/11/08
to Rhino...@googlegroups.com
I think so, can't recall off the top of my head
Reply all
Reply to author
Forward
0 new messages