Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / July 2003

Tip: Looking for answers? Try searching our database.

Appdomain.CreateInstanceFromAndUnwrap

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ralf Berkvens - 17 Jul 2003 07:45 GMT
Hi!
I am trying to load an instance of a framework class from an assembly, but I
must always be sure to have the latest version of the assembly.

I have tried with reflection.assembly.loadFrom, which worked, except that
once the assembly was loaded, it never loaded an updated version. In a
constantly running website, this will not do.

So I'm trying to load it using CreateInstanceFromAndUnwrap in an appdomain
that temporarily exists, and which is unloaded after using the class i need.
The problem is: first it says that the Class i want to load in not
serializable. OK, I make it serializable, and then it tells me it cannot
find the assembly DLL or one of it's dependancies. How then did it know my
class was not serializable???

Will this method actually get me anywhere, or am I barking up the wrong tree
here?

thanks for any helpful comments,
Ralf
Allen Jones - 17 Jul 2003 14:54 GMT
Ralf,

You say you are trying to load an instance of a "framework class", but the
tail end of your post indicates that it is a custom class. What class are
you trying to load? Can you post the class declaration (without the full
implementation).

If you want to load the class into another app domain and interact with it
in that appdomain, then it needs to be a pass-by-reference class (derived
from MarshalByRefObject). If you access a serializable object in another app
domain, you will end up with an instance of that object in both app domains.
If the class you need to work with is not pass by reference, then you will
need to create a controller class that is pass-by-reference, instantiate it
in the remote app domain, and use it as an intermediary to manipulate non
pass-by-ref code in the remote app domain.

Re the error you get, I dont know for sure, because I dont know the internal
process that the runtime uses, but I can imagine a situation where the
runtime loads your assembly (because you supply a specific file name), but
when it tries to load assemblies referenced by yours, it cannot find them
because they are not in a location where the runtime searches (probes) by
default.

Regards
Allen

> Hi!
> I am trying to load an instance of a framework class from an assembly, but I
[quoted text clipped - 16 lines]
> thanks for any helpful comments,
> Ralf
Ralf Berkvens - 18 Jul 2003 08:18 GMT
Sorry about the confusion between Framework and Custom. When I said
Framework, I didn't mean the .Net framework, but our own product framework;
my bad.

I will look into the rest of your comment, it sound like what I need,
thanks!

Ralf

> Ralf,
>
[quoted text clipped - 21 lines]
> Regards
> Allen

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.