Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalidCastException for two Objects of the same type
    primarykey
    data
    text
    <p>I have this weird problem that I cannot handle myself. A class in the model of my mvp-project designed as singleton causes an InvalidCastException. The source of error is found in this code line where the deserialised object is assigned to the instance variable of the class: <code>engineObject = (ENGINE)xSerializer.Deserialize(str);</code> It occurs whenever I try to add one of my UserControls to a Form or to a different UC. All of my UCs have a special presenter that access the above mentioned instance variable of the singleton class. This is what I get when trying to add a UC somewhere:</p> <p>'System.TypeInitializationException: The type initializer for 'MVP.Model.EngineData' threw an exception. ----> System.InvalidCastException: [A]Engine cannot be cast to [B]Engine. Type A originates from 'MVP.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location '[...]\AppData\Roaming\Microsoft\VisualStudio\9.0\ProjectAssemblies\uankw1hh01\MVP.Model.dll'. Type B originates from 'MVP.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location '[...]\AppData\Roaming\Microsoft\VisualStudio\9.0\ProjectAssemblies\u_hge2de01\MVP.Model.dll'...</p> <p>So I somehow have two assemblies and they are not accessed from my project folder, but from a VS temp folder? I googled a lot and only found this: <a href="http://www.darrellhawley.com/2009/02/ironpython-exception-aperson-cannot-be.html" rel="noreferrer">IronPython Exception: [A]Person cannot be cast to [B]Person</a>. There is a solution offered, but first it concerns IronPhyton and second I don't know where to use it within my project? </p> <p>It would be just great, if u could help me out here :-) thx</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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