0

我对 crm 2011 的这个插件部分完全陌生。

我写了一个简单的插件。生成了一个 xrm.cs 文件并尝试注册插件,但它给出了一些“超时异常”后来我从我的解决方案中删除了 Xrm.cs 文件,然后插件被注册了。我不明白为什么会这样。

下面是我没有被调用的简单插件代码,可能是因为我删除了 Xrm.cs 文件。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using System.Runtime.Serialization;




namespace NewPlugin
{
public class Plugin : IPlugin
{
    /// <summary>
    /// A plugin that creates a follow-up task activity when a new account is created.
    /// </summary>
    /// <remarks>Register this plug-in on the Create message, account entity,
    /// and asynchronous mode.
    /// </remarks>
    public void Execute(IServiceProvider serviceProvider)
    {
        //Extract the tracing service for use in debugging sandboxed plug-ins.
        ITracingService tracingService =
            (ITracingService)serviceProvider.GetService(typeof(ITracingService));
        account 
        // Obtain the execution context from the service provider.
        IPluginExecutionContext context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));

        // The InputParameters collection contains all the data passed in the message request.
        if (context.InputParameters.Contains("Target") &&
            context.InputParameters["Target"] is Entity)
        {
            // Obtain the target entity from the input parameters.
            Entity entity = (Entity)context.InputParameters["Target"];

            throw new InvalidPluginExecutionException("not Possible");

        }
    }
}
}

如果有人可以告诉我我的 Xrm.cs 文件出了什么问题,那将有很大帮助。

这是我在帐户页面上单击创建按钮的异常

Unhandled Exception:    System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An error occurred. Contact a system administrator or refer to the Microsoft Dynamics CRM SDK troubleshooting guide.Detail: 
<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>OperationStatus</d2p1:key>
  <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>An error occurred. Contact a system administrator or refer to the Microsoft Dynamics CRM SDK troubleshooting guide.</Message>
<Timestamp>2013-10-28T04:51:39.2540481Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>

[ActivityFeeds.Plugins: ActivityFeeds.Plugins.ActivityClose]
[34685442-783d-e311-a318-b4b52f6727c4: ActivityFeeds.Plugins.ActivityClose: Create of account]

4

1 回答 1

0

可能您不是部署管理器(您可以在 crm 组织管理器中检查它)并且该插件未在隔离模式下注册。您可以尝试在 sdk (SDK\Tools\DeveloperToolkit) 中安装 crm 开发人员工具包,以便于部署/注册。这将允许创建一个带有包、插件项目的新解决方案,如果连接到正确的 crm 和解决方案,您将能够让 VS 为您创建基类。

于 2013-11-07T22:58:43.283 回答