locked
Is there a way of troubleshooting Unit Test Adapter exception? RRS feed

  • Question

  • There are many posts and blog entries on dreadful "Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..".  The only solution I have seen is elimination. Try this or that, rollback and it may work again. Well, I've tried all I can think of and none of the unit tests in the projects run. All I get is

    "Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.."

    There are two unit tests projects in the solution, only one is affected.

    I understand that it has to do something with Reflection not being able to load some class, but my question is this - how do I troubleshoot it? How can I get more details? Is there aditional logging that can be enabled? Where is this LoadedException property? Burried somewhere in MSTest? It is a big unit test project and I don't have time to go back multiple revisions back hoping that by doing this I will figure out it. I would like to know what exactly MSTest cannot load.

    -Stan

    Monday, March 26, 2012 1:20 PM

Answers

  • I am answering my own question. Build a console app:

    private static void Main(string[] args)
            {
                try
                {
                    Type[] types = Assembly.LoadFrom("..\\..\\MyUnitTests.dll").GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    foreach (var loaderException in ex.LoaderExceptions)
                    {
                        Console.WriteLine(loaderException.Message);
                    }
                    Console.WriteLine("..");
                }
            }

    and you'll find out.. In my case one of the references had Copy Local set to false, in others it can be assembly signing or anything else..
    Tuesday, March 27, 2012 12:38 PM

All replies

  • I am answering my own question. Build a console app:

    private static void Main(string[] args)
            {
                try
                {
                    Type[] types = Assembly.LoadFrom("..\\..\\MyUnitTests.dll").GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    foreach (var loaderException in ex.LoaderExceptions)
                    {
                        Console.WriteLine(loaderException.Message);
                    }
                    Console.WriteLine("..");
                }
            }

    and you'll find out.. In my case one of the references had Copy Local set to false, in others it can be assembly signing or anything else..
    Tuesday, March 27, 2012 12:38 PM
  • Hi Stan,

    Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions. I mark your reply as the answer.

    Have a nice day,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 28, 2012 2:29 AM