I did update, or at least I thought I did, here is a message I get now and I
think it's the same and I'm positive that the assemblies has now been built
against version 2.2.0.6628.
System.TypeLoadException : Type
'Castle.Proxies.ITypeWithFakeablePropertiesProxy' from assembly
'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' is attempting to implement an inaccessible interface.
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.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.GenerateCode(Type
proxyTargetType, Type[] interfaces, ProxyGenerationOptions options)
at
Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(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 Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type
interfaceToProxy, Type[] additionalInterfacesToProxy, IInterceptor[]
interceptors)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(85,0): at
FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.CreateInterfaceProxy(Type
typeToProxy, IEnumerable`1 additionalInterfacesToImplement,
FakeObjectInterceptor fakeObjectInterceptor)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(145,0): at
FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.DoGenerateProxy(Type
typeToProxy, IEnumerable`1 additionalInterfacesToImplement, FakeObject
fakeObject, IEnumerable`1 argumentsForConstructor)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(50,0): at
FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.GenerateProxy(Type
typeToProxy, IEnumerable`1 additionalInterfacesToImplement, FakeObject
fakeObject, IEnumerable`1 argumentsForConstructor)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\Core\Creation\DefaultFakeAndDummyManager.cs(119,0):
at FakeItEasy.Core.Creation.DefaultFakeAndDummyManager.CreateProxy(Type
typeOfProxy, IEnumerable`1 additionalInterfacesToImplement, IEnumerable`1
argumentsForConstructor, Boolean throwOnFailure)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\Core\Creation\DefaultFakeAndDummyManager.cs(63,0): at
FakeItEasy.Core.Creation.DefaultFakeAndDummyManager.CreateFake(Type
typeOfFake, FakeOptions options)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\Core\Creation\DefaultFakeCreator.cs(39,0): at
FakeItEasy.Core.Creation.DefaultFakeCreator.CreateFake[T](Action`1 options)
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy\A.cs(40,0): at FakeItEasy.A.Fake[T]()
C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong
Name\Source\FakeItEasy.IntegrationTests\GeneralTests.cs(22,0): at
FakeItEasy.IntegrationTests.GeneralTests.Faked_object_with_fakeable_properties_should_have_fake_as_default_value()
This update leads to another unfortunate side-effect though, which is pretty
much my fault to begin with, 'cause I've made a bit of a hack. The thing is
that DynamicProxy doesn't intercept the object-members (ToString,
GetHashCode and Equals) which is a big issue for me becuase I really want to
be able to intercept those methods in order to configure them on
mocks/stubs. The way I've gotten around this is to have all proxies I
generate implement a special interface:
internal interface ICanInterceptObjectMembers
{
string ToString();
bool Equals(object o);
int GetHashCode();
}
When updating to the latest version these methods are no longer intercepted.
Is there any way around this?
/Patrik
2010/4/19 Krzysztof Koźmic <[email protected]>
> Check with Dynamic Proxy v2.2 if the issue occurs.
>
> Krzysztof
>
>
>
> On 2010-04-19 18:57, Patrik Hägne wrote:
>
>> I'm in the process of putting out a signed version of FakeItEasy
>> (http://code.google.com/p/fakeiteasy/) that is using DynamicProxy2.
>> When doing this some of my integration tests fails with an exception
>> message similar to the one below. Also when deploying the new, signed
>> verision in a large application with thousands of tests that uses
>> FakeItEasy something like 30% of the tests fails with a similar
>> exception. I have the InternalsVisibleTo-attribute for DynamicProxy2
>> set on all FakeItEasy-assemblies like this:
>>
>> [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2,
>>
>> PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
>>
>> The exception:
>>
>> System.TypeLoadException : Type
>> 'ITypeWithFakeablePropertiesProxy3d17a4446fea440f9c91aec9693fd7d7'
>> from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0,
>> Culture=neutral, PublicKeyToken=null' is attempting to implement an
>> inaccessible interface.
>> 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.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type
>> interfaceToProxy, Type[] additionalInterfacesToProxy,
>> ProxyGenerationOptions options, IInterceptor[] interceptors)
>> at
>> Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type
>> interfaceToProxy, Type[] additionalInterfacesToProxy, IInterceptor[]
>> interceptors)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(85,0):
>> at
>>
>> FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.CreateInterfaceProxy(Type
>> typeToProxy, IEnumerable`1 additionalInterfacesToImplement,
>> FakeObjectInterceptor fakeObjectInterceptor)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(145,0):
>> at
>> FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.DoGenerateProxy(Type
>> typeToProxy, IEnumerable`1 additionalInterfacesToImplement, FakeObject
>> fakeObject, IEnumerable`1 argumentsForConstructor)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\DynamicProxy\DynamicProxyProxyGenerator.cs(50,0):
>> at
>> FakeItEasy.DynamicProxy.DynamicProxyProxyGenerator.GenerateProxy(Type
>> typeToProxy, IEnumerable`1 additionalInterfacesToImplement, FakeObject
>> fakeObject, IEnumerable`1 argumentsForConstructor)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\Core\Creation\DefaultFakeAndDummyManager.cs(119,0):
>> at
>> FakeItEasy.Core.Creation.DefaultFakeAndDummyManager.CreateProxy(Type
>> typeOfProxy, IEnumerable`1 additionalInterfacesToImplement,
>> IEnumerable`1 argumentsForConstructor, Boolean throwOnFailure)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\Core\Creation\DefaultFakeAndDummyManager.cs(63,0):
>> at FakeItEasy.Core.Creation.DefaultFakeAndDummyManager.CreateFake(Type
>> typeOfFake, FakeOptions options)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\Core\Creation\DefaultFakeCreator.cs(39,0): at
>> FakeItEasy.Core.Creation.DefaultFakeCreator.CreateFake[T](Action`1
>> options)
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy\A.cs(40,0): at FakeItEasy.A.Fake[T]()
>> C:\Users\Patrik\Documents\Code\FakeItEasy\FakeItEasy - Strong Name
>> \Source\FakeItEasy.IntegrationTests\GeneralTests.cs(22,0): at
>>
>> FakeItEasy.IntegrationTests.GeneralTests.Faked_object_with_fakeable_properties_should_have_fake_as_default_value()
>>
>> I spoke to Krzysztof via e-mail and he suggested that I should update
>> to the latest version (2.2) and I've just tried that but I get the
>> same error.
>>
>> Any ideas? I could provide you with the full source if you'd like for
>> debugging.
>>
>> Cheers,
>> Patrik
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to [email protected]
> .
> To unsubscribe from this group, send email to
> [email protected]<castle-project-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
>
--
Patrik Hägne
Rosenbergsgatan 18B
254 44 HELSINGBORG
SWEDEN
Tfn: +46 (0) 701 64 85 52
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" 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/castle-project-users?hl=en.