Question

I have a Class Library (dll) that holds operations with reports. My dll needs a object to fill the desired report.

The problem is that I can't convert the object from my main .exe to the same object in the dll.

 [A]MyMainEXE.Model.MyObject can't be converted to [B]MyClassLibrary.Model.MyObject 
 The type A cames from 'MyMainEXE', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 
 in the context 'Default' at 
 'C:\fakepath\DummyName.exe'. 
 The type B cames from 'MyClassLibrary', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 
  in the context 'Default' at
 'C:\fakepath\DummyName.dll'

I'm just trying to pass like this:

doWorks(myObjectname);

and receive like this:

public void doWorks(object myobject)
{
 MyObject thing = (MyObject) myobject;
   //Do something
}

I already know how to pass using a array or List but

Why can't I do with objects?/What am I doing Wrong?

Was it helpful?

Solution

Since both objects are of the same name but probably different namespace, I think you have to serialize/deserialize the object from MyMainEXE.Model.MyObject to XML/Binary to MyClassLibrary.Model.MyObject

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top