Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Bug? Load Assembly With Generic Type
    text
    copied!<p>I have an class that loads the assembly dynamically like so:</p> <pre><code> Assembly asm = Assembly.LoadFile(args[1]); runner.RunTestOnAssembly(asm); </code></pre> <p>then another class runs the test on that assembly:</p> <pre><code> foreach (var cspecType in asm.GetTypes()) { RunTestOnType(cspecType); } </code></pre> <p>The loaded assembly references other assemblies in the same folder, <strong>[Debug\Tests]</strong> and the program that loads the assembly is in the <strong>[Debug]</strong> folder.</p> <p>The loaded Assembly (CalcSpecAsm):</p> <pre><code> public class CalcSpec : CSpecFacade&lt;ICalc&gt; { public CalcSpec() : base(new Calc()) { } } </code></pre> <p>The referenced Assembly (CalcAsm):</p> <pre><code> public class Calc : ICalc { /// &lt;summary&gt; /// Initalisation constructor /// resets the Total value. /// &lt;/summary&gt; public Calc() { Total = 0; } ..... </code></pre> <p>The CSpecFacade is referenced in another assembly.</p> <p>And now the problem is that if I load the assembly CalcSpecAsm I get assembly loaderError on GetTypes() that it cannot resolve a reference to CalcAsm assembly.</p> <p>The problem is this line of code: <code>public class CalcSpec : CSpecFacade&lt;ICalc&gt;</code></p> <p>If I remove the generic arg ICalc and initize it in the constructor then it works perfect but that's not what I'm after.</p> <p>BUT: If i copy the loaderAssembly program to the <strong>[Debug\Test]</strong> and then run it, everything works fine.</p> <p>How to resolve the problem, and what causes it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload