Latest Blog Post:
Dynamics 365 v9 Unit Testing and .NET Confusion
7/12/2018 6:13:00 PM
Recently while creating a plugin for Dynamics 365 v9, I ran into an issue trying to connect to CRM via the tooling connector in my unit test project. The underlying problem was that the .NET version I was using in my unit test was 4.5.2. This was preventing me from being able to connect to CRM to create my organization service. I updated the .NET version on my unit test project to 4.6.1 and was then finally able to connect. I will also add that I am using the latest nuget package version for Dynamics 365 v9.
For consistence, I updated the plugin project I was working on to .NET 4.6.1. Locally, everything was working great. I was able to connect to CRM and make sure that all the methods I had written did what they where suppose to do using test driven development practices.
Then when publishing my plugin via the latest version of the plugin registration tool, I received an error and could not publish my plugin. The error was due to the .NET version of my plugin project not being 4.5.2. REALLY!!!! I just had connection issues and needed to upgrade the .NET version to 4.6.1 to resolve them. Now I am being told to downgrade my .NET version to upload the plugins to Dynamics 365 v9.
While researching this, I came across this thread in the Microsoft forums
, where people are seeing the same issue and are confused as to what is happening. Basically, CRM plugins need to use .NET 4.5.2 but the XRM tooling connector uses .NET 4.6.1. We need to tooling connector in our unit tests, because we are connecting to CRM via an external source to create the organization service context for us. This means that our unit test project needs to be built on .NET 4.6.1 and out plugin project needs to be built on .NET 4.5.2. Don't worry, the nuget packages you need for both can work with both .NET versions without any problem and you will be able to connect to CRM from your unit test project and call methods from the plugin project to test your code. You will then be able to publish your plugins to CRM and not receive a .NET error message in the plugin registration tool.