When running your application on another machine are you getting the following error ‘Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.’? Most of the time this is due to a dll or other piece of code not being included in the build file and it doesn’t exist on the new machine. To find out which piece of code is missing you can use the following code :
NOTE: in the following code, logger is a NLog logger object.
// Code you are trying to run.
catch (Exception ex)
if (ex is ReflectionTypeLoadException)
var typeLoadException = ex as ReflectionTypeLoadException;
var loaderExceptions = typeLoadException.LoaderExceptions;
foreach (var loaderException in loaderExceptions)
logger.ErrorException("Loader Exception.", loaderException);
logger.ErrorException("Error while running", ex);
Now all you have to do is look at your error log to see which dll’s are missing and make sure that they are being added into your build.