chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes

I am getting some type errors that appear to have something to do with assembly identity.  Here is the test code:

ICandidateScorer ifScorer =
    InterfaceLoader.InstantiateInterface<ICandidateScorer>(sAlphaTraderAsy, sAlphaPredictorScorer);
Assert.IsInstanceOfType(ifScorer, typeof(AlphaPredictorScorer));
ifScorer.Initialize(sScorerFile);
AlphaPredictorScorer scorerAP = (AlphaPredictorScorer)ifScorer;
The Assert.IsInstanceOfType() is failing which the following message:
Assert.IsInstanceOfType failed.
    Expected type:<Kent.AlphaTrader.AlphaPredictorScorer>.
    Actual type:<Kent.AlphaTrader.AlphaPredictorScorer>.

The cast from ifScorer to scorerAP is failing with the following exception:

System.InvalidCastException :
    [A]Kent.AlphaTrader.AlphaPredictorScorer cannot be cast to
    [B]Kent.AlphaTrader.AlphaPredictorScorer.
    Type A originates from 'AlphaTrader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:UserskentrDocumentsProjectsExcessionAlphaTrader.UnitTestinDebugAlphaTrader.dll'.
    Type B originates from 'AlphaTrader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:UserskentrAppDataLocalTempTypemockExcessionTypemock.SmartRunner.Agent.exessemblydl34a603408e132_ad89d201AlphaTrader.dll'.

It appears the the Typemock test runner is modifying the original assembly such that .NET no longer recognizes the types that the code was originally compiled against.

Is there a way to deal with this?

 

asked by KentRollins (2.7k points)

1 Answer

+1 vote
 
Best answer

Hi,

This can happen when the assembly is loaded from different dlls. You probrably have your own Assembly loader within InterfaceLoader.

Please try to disable smartRunner from running in shadowcopy. (see here)

answered by eli (5.7k points)
selected by KentRollins
...