AppDomain Casting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rain

    #1

    AppDomain Casting

    AppDomain appDomain = AppDomain.Creat eDomain("appDom ain", null, null);
    try
    {
    appDomain.Appen dPrivatePath(@" C:\DLLS\");
    appDomain.Load( @"FF-DeliousDateTime Requestor");

    ObjectHandle o = appDomain.Creat eInstance("FF-DeliousDateTime Requestor",
    "DeliousTools.L oader");
    object ob = o.Unwrap();
    IDeliousToolsIn t obj = (IDeliousToolsI nt)ob;
    obj.Start();
    }
    finally
    {
    AppDomain.Unloa d(appDomain);
    }

    Does anyone know how to solve this exception:

    An unhandled exception of type 'System.Invalid CastException' occurred in
    NewerDeliousLau ncher.exe

    Additional information: Specified cast is not valid.

    The error occurs in this line:
    IDeliousToolsIn t obj = (IDeliousToolsI nt)ob;

    Thank you in advance!
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: AppDomain Casting

    Hi,


    [color=blue]
    > Does anyone know how to solve this exception:
    >
    > An unhandled exception of type 'System.Invalid CastException' occurred in
    > NewerDeliousLau ncher.exe
    >
    > Additional information: Specified cast is not valid.
    >
    > The error occurs in this line:
    > IDeliousToolsIn t obj = (IDeliousToolsI nt)ob;
    >[/color]

    Put a breakpoint in the line above, what type is reported?

    Is your IDeliousToolsIn t the very same interface than the one you are
    creating?

    My bet is that you define the same interface in two different places, if you
    did you cannot cast one to other as they are differents.



    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    Comment

    Working...