-
-
Notifications
You must be signed in to change notification settings - Fork 813
TypeLoad Exception #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Plz try to repro with plain DynamicProxy or NSubstitute / FakeItEasy. If it On Fri, Jan 15, 2016, 12:47 AM shanepcarr [email protected] wrote:
|
OK I will give that a shot and let you know Sent from Outlook Mobile On Thu, Jan 14, 2016 at 8:06 PM -0800, "Daniel Cazzulino" [email protected] wrote: Plz try to repro with plain DynamicProxy or NSubstitute / FakeItEasy. If it On Fri, Jan 15, 2016, 12:47 AM shanepcarr [email protected] wrote:
Reply to this email directly or view it on GitHub: |
Thanks again for the response. I figured out this problem, it had nothing to do with castle or MOQ. Posting the resolution as other people will likely face similar issue and this investigation may help. The problem was we had a custom build assembly that didn't match assembly which was getting loaded from the gac before my suite ever ran, but we had built against the custom built assembly. The lesson is to break on exceptions and look at the loaded modules to double check that you have the right assemblies loaded then look at the il. This was tricky because this assembly was being loaded by vs and we have a custom built version improperly versioned which I didn't know about. |
The scenario: We are having a problem mocking an interface which is public. It is in a signed assembly which is a dependency of our dev code (we don't directly own the assembly).
The interface has a number return values which are concrete types (on methods i am not directly using our testing) and they are public. If i remove personal the problem just moves down to the next class.
For example these methods
ICollection DirectorySearch(ViewBase view, string queryString);
and
FindPeopleResults FindPeople(WellKnownFolderName wellKnownFolderName, SearchFilter filter, ItemView view);
Everything is public (no internal visible to i believe should be required). I don't see any reason these shoudl be casuing this type of issue, i am not actually mocking these or using these properties in my code the exception happens on the ".object" to generate the mock.
GetConversationScreenResponse getConversationScreenResponse = this.NewGetConversationScreenCommand(serviceMock.Object, flowFolderMock.Object).Execute(flowConversationId);
We also aren't mocking any of these methods that are causing the problem. it seems to be triggered by reflection in moq scanning the object and throwing an exception. I included the call stack below and the call stack from the test case. I spent a while on this any suggestions would be greatly appreciated!
Test Name: SingleFlowOriginatedOneOnOneMessageInConversation
Test FullName: Microsoft.OutlookApps.Flow.Api.Tests.GetConversationScreenCommandTests.SingleFlowOriginatedOneOnOneMessageInConversation
Test Source: C:\Users\shcarr\wp\gservice\GroupiesCloudService\DirectMessagingApi.Tests\GetConversationScreenCommandTests.cs : line 59
Test Outcome: Failed
Test Duration: 0:00:00.0089433
Result StackTrace:
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at Castle.DynamicProxy.Generators.MethodSignatureComparer.GetHashCode(MethodInfo obj)
at System.Collections.Generic.Dictionary
2.FindEntry(TKey key) at Castle.DynamicProxy.Generators.MethodFinder.RemoveDuplicates(MethodInfo[] infos) at Castle.DynamicProxy.Generators.MethodFinder.GetAllInstanceMethods(Type type, BindingFlags flags) at Castle.DynamicProxy.Contributors.MembersCollector.CollectMethods(IProxyGenerationHook hook) at Castle.DynamicProxy.Contributors.MembersCollector.CollectMembersToProxy(IProxyGenerationHook hook) at Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.<CollectElementsToProxyInternal>d__0.MoveNext() at Castle.DynamicProxy.Contributors.CompositeTypeContributor.CollectElementsToProxy(IProxyGenerationHook hook, MetaType model) 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 Microsoft.OutlookApps.Flow.Api.Tests.GetConversationScreenCommandTests.SingleFlowOriginatedOneOnOneMessageInConversation() in C:\Users\shcarr\wp\gservice\GroupiesCloudService\DirectMessagingApi.Tests\GetConversationScreenCommandTests.cs:line 67
Result Message:
Test method Microsoft.OutlookApps.Flow.Api.Tests.GetConversationScreenCommandTests.SingleFlowOriginatedOneOnOneMessageInConversation threw exception:
System.TypeLoadException: Could not load type 'Microsoft.Exchange.WebServices.Data.Persona' from assembly 'Microsoft.Exchange.WebServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Here is some sample code that seems to be causing the problem.
namespace Microsoft.Exchange.WebServices.Data
{
[Attachable, ServiceObjectDefinition("Persona")]
public class Persona : Item
...
The text was updated successfully, but these errors were encountered: