2017-09-20 2 views
0

Ich habe Probleme beim Debuggen meiner Assembly mit dem PluginProfiler, der mit dem PluginRegistrationTool ausgeliefert wird. Sobald ich den Schritt als Profilierung markieren und auslösen (Konto erstellen) es wird folgende Fehlermeldung angezeigt:Dynamic CRM 2016 PluginProfiler System.TypeLoadException

Unhandled Exception: 

System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected Exception in the Plug-in ProfilerDetail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"> 
    <ErrorCode>-2147220891</ErrorCode> 
    <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
    <KeyValuePairOfstringanyType> 
     <d2p1:key>CallStack</d2p1:key> 
     <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"> at PluginProfiler.Plugins.ProfilerBase`1.InitializeProfiler(Dictionary`2 services, T operationContext, ProfilerPluginContext&amp; context) 
    at PluginProfiler.Plugins.ProfilerPlugin.Execute(IServiceProvider serviceProvider) 
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass8.&lt;Execute&gt;b__1() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain) 
    at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain) 
    at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</d2p1:value> 
    </KeyValuePairOfstringanyType> 
    <KeyValuePairOfstringanyType> 
     <d2p1:key>OperationStatus</d2p1:key> 
     <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">3</d2p1:value> 
    </KeyValuePairOfstringanyType> 
    <KeyValuePairOfstringanyType> 
     <d2p1:key>SubErrorCode</d2p1:key> 
     <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value> 
    </KeyValuePairOfstringanyType> 
    </ErrorDetails> 
    <Message>Unexpected Exception in the Plug-in Profiler</Message> 
    <Timestamp>2017-09-20T11:11:16.7252255Z</Timestamp> 
    <ExceptionRetriable>false</ExceptionRetriable> 
    <ExceptionSource i:nil="true" /> 
    <InnerFault i:nil="true" /> 
    <OriginalException i:nil="true" /> 
    <TraceText> 

[PluginProfiler.Plugins: PluginProfiler.Plugins.ProfilerPlugin] 
[585cb523-f29d-e711-81b0-000d3a22c45c: XXXXXXXX.Xrm.Plugins.BasicEntryPoints.GenericPlugin: Create of account (Profiler)] 

An exception occurred during the initialization of the Plug-in Profiler. 
Unhandled Exception: System.TypeLoadException: Inheritance security rules violated while overriding member: 'Castle.DynamicProxy.ProxyGenerationOptions.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. 
    at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) 
    at System.Reflection.RuntimeAssembly.GetExportedTypes() 
    at Microsoft.Xrm.Sdk.KnownTypesProvider.get_KnownOrganizationRequestResponseTypes() 
    at Microsoft.Xrm.Sdk.KnownTypesResolver.ResolveName(String typeName, String typeNamespace, Type declaredType, DataContractResolver knownTypeResolver) 
    at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromDataContractResolver(XmlQualifiedName typeName, Type declaredType) 
    at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromKnownTypes(String typeName, String typeNs, DataContract memberTypeContract, Type declaredType) 
    at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Type declaredType) 
    at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Dictionary`2 knownDataContracts, Type declaredType) 
    at System.Runtime.Serialization.KnownTypeDataContractResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString&amp; typeName, XmlDictionaryString&amp; typeNamespace) 
    at Microsoft.Xrm.Sdk.KnownTypesResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString&amp; typeName, XmlDictionaryString&amp; typeNamespace) 
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.ResolveType(Type objectType, Type declaredType, XmlDictionaryString&amp; typeName, XmlDictionaryString&amp; typeNamespace) 
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteTypeInfo(XmlWriterDelegator writer, DataContract contract, DataContract declaredContract) 
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) 
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph) 
    at Microsoft.Crm.Sandbox.SandboxUtility.SerializeDataContract[T](T dataContract, Assembly proxyTypesAssembly) 
    at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request) 
    at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.RetrieveInternal(String entityName, Guid id, ColumnSet columnSet) 
    at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.Retrieve(String entityName, Guid entityId, ColumnSet columnSet) 
    at PluginProfiler.Plugins.PluginLoaderUtility.RefreshAssembly(IOrganizationService service, ProfilerConfiguration config, PluginInitializationContext context) 
    at PluginProfiler.Plugins.PluginLoaderUtility.RefreshPluginInitializationContext(IOrganizationServiceFactory factory, ProfilerConfiguration config, PluginInitializationContext currentContext) 
    at PluginProfiler.Plugins.ProfilerBase`1.InitializeProfiler(Dictionary`2 services, T operationContext, ProfilerPluginContext&amp; context) 



</TraceText> 
</OrganizationServiceFault> 

Ich StructureMap als IoC-Container mit und StructureMap.AutoFactory, die Castle.Core erfordert. Ich verwende ILMerge, um alle Assemblies zu einem einzigen on zusammenzuführen. Ich verwende die folgenden Argumente ILMerge auszuführen:

/target:library 
/out:"$outPath" 
/log:"$logFile" 
/keyfile:"${keyFile}" 
/copyattrs 
/wildcards 
/targetplatform:"v4,${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2" 

und die folgenden Baugruppen (links aus meiner dlls):

"${targetDir}StructureMap.dll" 
"${targetDir}StructureMap.AutoFactory.dll" 
"${targetDir}Castle.Core.dll" 

Ich bin wirklich aus Ideen und es wäre toll, wenn jemand findet die Zeit, mir zu helfen. Danke im Voraus!

Antwort

0

Gemäß this article verhindert die Sandbox-Umgebung, in der Plugins ausgeführt werden, die Verwendung von Reflection für den Zugriff auf interne Member. Ich bin nicht vertraut mit Dynamics Proxying per se, aber es sieht so aus, als ob man Typen on-the-fly erstellen würde, und möglicherweise ist die Verwendung von Reflektion in dem Prozess in der Sandbox möglicherweise nicht möglich.

Wenn Sie eine On-Prem-Entwicklungsumgebung haben, können Sie das Plugin außerhalb der Sandbox registrieren und sehen, was passiert.