Update: Trying out the .NET 4.0 Beta fixes the issue.

On Feb 2, 11:44 am, Mike F <[email protected]> wrote:
> A large project I'm working on has been using Rhino Mocks without any
> problems for a couple years. But recently, we started seeing
> AccessViolationExceptions occur seemingly randomly in our unit tests
> when calling StrictMock<T>().
>
> After experimentation, I found that it seems to occur on 64-bit
> machines when mocking about 1000 different interfaces in the same
> program execution.
> The uploaded project "AccessViolationException_ExampleProject.zip"
> demonstrates this.
>
> Exception:
> Unhandled Exception: System.AccessViolationException: Attempted to
> read or write protected memory. This is often an indication that other
> memory is corrupt.
>    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.Emitters.AbstractTypeEmitter.BuildType
> ()
>    at
> Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCo de
> (Type proxyTargetType, Type[] interfaces, ProxyGenerationOptions
> options)
>    at
> Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarg et
> (Type interfaceToProxy, Type[] additionalInterfacesToProxy,
> ProxyGenerationOptions options)
>    at
> Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget
> (Type interfaceToProxy, Type[] additionalInterfacesToProxy,
> ProxyGenerationOptions options)
>    at
> Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget
> (Type interfaceToProxy, Type[] additionalInterfacesToProxy,
> ProxyGenerationOptions options, 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.StrictMock[T](Object[]
> argumentsForConstructor)
>    at _10001Dalmatians.Program.Main() in c:\development\personal
> \10001Dalmatians\10001Dalmatians\Program.cs:line 1028
>
> Even if this is an inescapable limitation, I would much more prefer
> that the exception were more explicit so I wouldn't have to
> investigate unrelated recent changes in the project.
> Given the stack trace, I suspect it isn't a problem with Rhino Mocks,
> but rather with Castle.DynamicProxy or .NET itself. (I also submitted
> a bug report a few days ago to 
> Castle.DynamicProxy:http://support.castleproject.org/projects/DYNPROXY/issues/view/DYNPRO...
> )

-- 
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