Ok,Fox,Im still with my problem, ill try to be clearer

  • Thread starter Thread starter Daylor
  • Start date Start date
D

Daylor

first of all , PLEASE,say somthing..about my post.
any reply will be nice to read.

i have vb.app , with 2 appdomains.
(now, in the next section , ill write "appdomain create" ,means a code in
the appdomain is creating )

appdomain2 call appdomain 1 to create object of type "CCar" (the param is
string )
the appdomain1 creating a object from assembly file. ( the object is ofthe appdomain1 dont know the type of this object he just created , and keep
the instance in >>Object type<<.

appdomain1 sending back >>object type<< to appdomain2. (now, as i know,
because its between appdomains , a proxy is send)

now here is the PROBLEM:

appdomain2 , get the object of >>Object Type<< ,
and want to cast it to the real object type that is >> CCar Type <<.

when appdomain 2 try to cast the >>Object Type<< to >>CCar Type << , an
exception is throw of :

A first chance exception of type 'System.InvalidCastException'
occurred in MyAssembly.dll
Additional information: Specified cast is not valid.


now here is the code sample in appdomain 2:

------------------------------
dim obj as object
dim myCar as CCar

obj = m_someObjectInAppdomain1.CreateThisClass ( "CCar")

myCar = CType(obj , CCar) // throw 'System.InvalidCastException'

------------------------------

can someone explain what im missing here ?
and how can i cast an object i recive from other appdomain ?

hope this clear.if not ,pls ask and explain any details.
im try to solve this problem for 2 day.

bye.
 
Does class CCar exist on appdomain2?

Why do you pass them as objects? Can't you pass the object by its real type?
 
hi.thanks for reply.and good you ask me to explain more.


1.the CCar exist on appdomain2. (it must know this type to do the cast to
ccar )
2.im passing it as object, cause i dont want the server to know this
type.its design issue.


now,why i can't cast the object to its real type ? any clue ?
 
Back
Top