OK, I was thinking about setting the PrivatePath on the AppDomain. However, how do I call Assembly.Load() even with the PrivatePath set? I only have the assembly file path and Assembly.Load() doesn't accept this as a parameter.
Thanks, Charles. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Taylor Sent: 16 May 2007 12:46 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Using Assembly.LoadFrom instead of Assembly.Load() > So my application code calls Assembly.LoadFrom() on the assembly, > executes the method and the returned class is used in the calling code. > However, I believe the calling code loads the assembly from the GAC in > the Load context (via a static reference) in order to define a variable > of the class returned from the method, and Assembly.LoadFrom() will > load > the assembly into the LoadFrom context. The class returned from the > method is not compatible with the class variable defined in the calling > code as they are in different contexts and I get the Invalid Cast > exception. I'm not sure I fully grasp what you're trying to do (sorry), but would separate AppDomains help? You could specify the private path (where Assembly.Load looks for DLLs) in the AppDomainSetup when you create the new AppDomain, and there'll be no conflict between that assembly and any other assembly in your current context. You can't pass objects between AppDomains, but you can serialise objects or pass MarshalByRefObject object references, so (with a bit of glue code in your new AppDomain) this may do what you need. Hope this helps, Geoff =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com ________________________________________________________________________ This e-mail has been scanned for all viruses by MessageLabs. ________________________________________________________________________ ________________________________________________________________________ This e-mail has been scanned for all viruses by MessageLabs. Singularity operates globally through its offices in New York, London, Singapore, Ireland and India. Singularity Limited is incorporated in the United Kingdom with Registration Number NI 31519 and its Registered Office at 100 Patrick Street, Derry, BT48 7EL, United Kingdom. ________________________________________________________________________ =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com