Dynamics 365 9.0插件开发,程序集和.NET Framework版本

时间:2019-06-01 18:29:47

标签: plugins dynamics-crm .net-framework-version dynamics-365

我正在尝试构建一个简单的插件库并将其注册到Dynamics 365 9.0本地安装中。

我指的是CRM SDK库v9.0.37.958

写的东西很简单;

public class TestEntityPluginLibrary : IPlugin
{
    public void Execute(IServiceProvider serviceProvider)
    {
        throw new InvalidPluginExecutionException("Hello there, this is an error!");
    }
}

如果我尝试针对.NET v4.6.2构建库,并尝试通过插件注册工具注册已构建的dll,则会在下面收到错误消息。

https://imgurp.com/rniToHx

This plugin assembly uses version 4.6.2 of the .NET Framework. 
At this time Microsoft Dynamics 365 requires version 4.5.2 of the .NET Framework for plugin assemblies.
Rebuild this assembly using .NET Framework version 4.5.2 and try again.

因此,我需要针对4.5.2进行构建。很公平。我通过项目属性将Target框架更改为4.5.2。 现在,当我尝试构建时,构建失败。

1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3274: The primary reference "Microsoft.Crm.Sdk.Proxy" could not be resolved because it was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.2".
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3274: The primary reference "Microsoft.Xrm.Sdk" could not be resolved because it was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.2".
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3275: The primary reference "Microsoft.Crm.Sdk.Proxy" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" which was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.2".
1>C:\Users\**\documents\visual studio 2015\Projects\Crm9\MyPluginLibrary\Plugins\TestEntityPluginLibrary.cs(1,17,1,20): error CS0234: The type or namespace name 'Xrm' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>C:\Users\**\documents\visual studio 2015\Projects\Crm9\MyPluginLibrary\Plugins\TestEntityPluginLibrary.cs(10,44,10,51): error CS0246: The type or namespace name 'IPlugin' could not be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

这时我迷路了。是否有我不知道的针对.NET v4.5.2构建的9.0 SDK的单独版本?如何针对.NET v4.5.2构建插件库?

1 个答案:

答案 0 :(得分:0)

找到以下答案;

https://community.dynamics.com/crm/f/117/t/315888

”,您需要在项目中定位到4.5.2,并且必须使用这些版本 Microsoft.CrmSdk.CoreAssemblies(9.0.2.5或更低版本) Microsoft.CrmSdk.Workflow(9.0.2.5或更低版本) 这些nuget软件包的最新版本需要4.6.2,并且您的本地版本尚不支持4.6.2(为此,您会收到错误消息) 开发者工具包与此无关”

Install-Package Microsoft.CrmSdk.CoreTools -Version 9.0.2.5

现在,我可以使用较旧的SDK针对4.5.2进行构建。 有时候我真的不了解微软...