Could not load type 'NameSpace.ClassName' from assembly 'AssemblyName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

时间:2017-04-06 17:07:19

标签: c# .net xamarin xamarin.ios typeloadexception

I am working on fixing broken tests for an iOS app made with Xamarin.
One of the tests is testing that a file downloads and the code is similar to this:

    public void DownloadFile(FileObject pProjectFile, string pTempFile, Action<DownloadEventArgs> pDownloadCallback)
    {
        ITransferUtility transfer = NameSpace.GetTransferUtility(pProjectFile);
        transfer.Download(pTempFile, pDownloadCallback);
    }

The problem is that I get a System.TypeLoadException Could not load type 'NameSpace.ClassName' from assembly 'AssemblyName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. when I call transfer.Download.

The assembly is a project in the solution.

What's weird is that if I do var type = Type.GetType("NameSpace.ClassName", true); there are no exceptions thrown.

Also, this doesn't happen when downloading a file through the app, it only occurs with the test project which is just a testrunner on top of the app.

A couple thing I've tried:

  • delete bin and obj from the testrunner project and the referenced assembly's project and do a clean and build of the solution
  • add [InternalsVisibleTo("TestRunnerProject)"] to the file with the class that is mentioned in the TypeLoadException.

I am running this on Xamarin for Mac so I don't have all the tools available that I've seen mentioned in other questions such as this one

0 个答案:

没有答案