Dynamics 365 code System.IO.FileNotFoundException Run Time error

The inspiration for today's blog post came while creating .NET, c# console applications to fix data and perform repetitive admin tasks in a clients Dynamics 365 instance. Keep reading to find the underlying cause of System.IO.FileNotFoundException and how assembly binding will resolve the error.

A number of the console apps built failed at run time with the error;

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (I wish I had taken a screen shot).

In general this error can occur when one assembly referenced in your visual studio project references a second assembly in your visual studio project how ever the second assembly is a different version. I know that is a heavy sentence to understand so there is an example in the next paragraph.

The error was occurring because the Microsoft.Crm.Sdk.Proxy ( and Microsoft.Xrm.Sdk ( assemblies were referenced in the visual studio project . The Microsoft.Crm.Sdk.Proxy ( assembly references (or looks for) Microsoft.Xrm.Sdk (, which does not exist in the project therefore the System.IO.FileNotFound exception occurs.

The quick fix is to add the below XML to the console applications app.config. This configures assembly binding which effectively is saying use Microsoft.Xrm.Sdk version 9 when trying to find Microsoft.Xrm.Sdk version 0 through to 9.

The below links from Microsoft will do a far better job than I could at explaining assembly versioning.

41 views1 comment

Recent Posts

See All

There are a number of tricks that can help improve the speed of data migrations. I have bullet pointed them below and included links and references at the bottom of the page. Turn off all workflows (i

Power Platform storage seems to get consumed very quickly. I have had to come up with capacity management strategies for numerous clients over the years. I really do wish Microsoft would increase the