Although heavy, you can, of course, use reflection to load the assembly for this test.
The following steps will not work:
var obj = new Newtonsoft.Json.Linq.JObject();
since the assembly does not exist yet. However, if I explicitly load it first through reflection and the absolute path to my mailbox, I can instantiate the object just fine.
var assembly = System.Reflection.Assembly.LoadFile("C:\\AbsolutePath\\bin\\Debug\\Newtonsoft.Json.dll"); var obj = new Newtonsoft.Json.Linq.JObject();
The reason for this need from the Immediate window is that when your application (or unit test application with the application extension in this case) loads, it searches for links in all code and loads the necessary assemblies to meet your needs. In your case, you do not have an explicit reference to the assembly in your code, so it does not load. The immediate window has no context and therefore you must explicitly load it.
To programmatically reference potential assemblies for download, you can use the bin directory of the downloaded assembly. This allows you to drag the absolute path at runtime.
var filePath = new Uri(this.GetType().Assembly.CodeBase).LocalPath; var bin = System.IO.Path.GetDirectoryName(filePath); var assembly = System.Reflection.Assembly.LoadFile(bin + "\\Newtonsoft.Json.dll");
source share