471,306 Members | 1,260 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

AppDomain Casting

AppDomain appDomain = AppDomain.CreateDomain("appDomain", null, null);
try
{
appDomain.AppendPrivatePath(@"C:\DLLS\");
appDomain.Load(@"FF-DeliousDateTimeRequestor");

ObjectHandle o = appDomain.CreateInstance("FF-DeliousDateTimeRequestor",
"DeliousTools.Loader");
object ob = o.Unwrap();
IDeliousToolsInt obj = (IDeliousToolsInt)ob;
obj.Start();
}
finally
{
AppDomain.Unload(appDomain);
}

Does anyone know how to solve this exception:

An unhandled exception of type 'System.InvalidCastException' occurred in
NewerDeliousLauncher.exe

Additional information: Specified cast is not valid.

The error occurs in this line:
IDeliousToolsInt obj = (IDeliousToolsInt)ob;

Thank you in advance!
Jan 27 '06 #1
1 1400
Hi,
Does anyone know how to solve this exception:

An unhandled exception of type 'System.InvalidCastException' occurred in
NewerDeliousLauncher.exe

Additional information: Specified cast is not valid.

The error occurs in this line:
IDeliousToolsInt obj = (IDeliousToolsInt)ob;


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

Is your IDeliousToolsInt 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
Jan 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Satinderpal Singh | last post: by
1 post views Thread by MatthewRoberts | last post: by
4 posts views Thread by Chris Lacey | last post: by
8 posts views Thread by A. Elamiri | last post: by
6 posts views Thread by Wal Turner | last post: by
4 posts views Thread by illegal.prime | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.