You may solve this issue by setting the Copy Local attribute of your project's references to true!
Instructions
1- In
Solution Explorer, click the
Show All Files button to display the References node.
2- Open the
References node for the project.
3- Right-click a reference in the References list, and click
Properties.
The properties associated with that reference appear in a list in the
Properties window.
4- Select
Copy Local from the left-hand column, and then click the arrow in the right-hand column to change the value to
True or
False.
You may also use the following code to identify what is missing
<pre lang="c#">
using System.IO;
using System.Reflection;
using System.Text;
try
{
//The code that causes the error goes here.
}
catch (ReflectionTypeLoadException ex)
{
StringBuilder sb = new StringBuilder();
foreach (Exception exSub in ex.LoaderExceptions)
{
sb.AppendLine(exSub.Message);
FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
if (exFileNotFound != null)
{
if(!string.IsNullOrEmpty(exFileNotFound.FusionLog))
{
sb.AppendLine("Fusion Log:");
sb.AppendLine(exFileNotFound.FusionLog);
}
}
sb.AppendLine();
}
string errorMessage = sb.ToString();
//Display or log the error based on your application.
}
References
msdn, stack overflow.