我在Visual Studio 2010中构建了一个自定义工作流活动,以便在Dynamics CRM 2013内部部署中使用,我尝试使用插件注册工具注册包含自定义工作流程的程序集,并配置:< strong> Sandbox 和数据库。我花了几个小时努力解决以下异常:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Exception retrieving custom activity info - Inheritance security rules violated by type: 'TrmIntergration.Workflow.BaseCodeActivity'. Derived types must either match the security accessibility of the base type or be less accessible.
Detail: <OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ErrorCode>-2147200995</ErrorCode>
<ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Exception retrieving custom activity info - Inheritance security rules violated by type: 'TrmIntergration.Workflow.BaseCodeActivity'. Derived types must either match the security accessibility of the base type or be less accessible.</Message>
<Timestamp>2014-07-31T09:58:46.057735Z</Timestamp>
<InnerFault>
<ErrorCode>-2147200995</ErrorCode>
<ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Exception retrieving custom activity info - Inheritance security rules violated by type: 'TrmIntergration.Workflow.BaseCodeActivity'. Derived types must either match the security accessibility of the base type or be less accessible.</Message>
<Timestamp>2014-07-31T09:58:46.057735Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
at Microsoft.Crm.Tools.Libraries.RegistrationHelper.RegisterPlugin(CrmOrganization org, CrmPlugin plugin)
at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.btnregisterClick()
这是活动代码:
using System;
using System.Activities;
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
namespace TrmIntergration.Workflow
{
public sealed class BaseCodeActivity: CodeActivity
{
[Output("Initiating User")]
[ReferenceTarget("systemuser")]
public OutArgument<EntityReference> InitiatingUserReference { get; set; }
protected override void Execute(CodeActivityContext executionContext)
{
IWorkflowContext workflowContext = executionContext.GetExtension<IWorkflowContext>();
InitiatingUserReference.Set(executionContext, new EntityReference("systemuser", workflowContext.InitiatingUserId));
}
}
}
答案 0 :(得分:0)
请检查blog。看起来像是同一个问题。
原因是某些旧版外部库不遵循.NET 4.0安全规则。它实际上非常简单的解决方案 - 恢复到.NET 2.0安全性。只需在代码内的任何位置添加以下属性(在using语句之后):
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
答案 1 :(得分:0)
您必须包含system.servicemodel
命名空间。