[英]Register custom workflow activity in Dynamics CRM 2013
我已經在Visual Studio 2010中構建了一個自定義工作流活動 ,以在Dynamics CRM 2013本地中使用,並且我嘗試使用具有以下配置的插件注冊工具來注冊包含自定義工作流的程序集: Sandbox和Database 。 我花了幾個小時努力解決以下異常:
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));
}
}
}
請檢查此博客 。 看起來是一樣的問題。
原因是某些舊版外部庫不遵循.NET 4.0安全規則。 該解決方案實際上非常簡單–恢復為.NET 2.0安全性。 只需在代碼內的任何位置(在using語句之后)添加以下屬性:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
您必須包括system.servicemodel
命名空間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.