Inline - and sometimes not funny :-)

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
--
Still writing SQL and dealing with DataSets?
    Why dont you use our EntityBroker.
    The most advanced o/r and business object toolkit in town.



-----Original Message-----
From: pralay [mailto:pralaypati@;YAHOO.COM] 
Sent: Montag, 28. Oktober 2002 07:25
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Problem is unloading assembly


Hi,
 I'm working on .NET remoting. I'm sending an object from client machine
to server by using .NET remoting. Client first gets the proxy of the
server, then calls a method of that proxy which takes the object as
argument. Now before sending the object, I'm also sending the dll
containing the class definition for the object to the server by similar
mechanism. Now, after completion of execution of the server method,
which is called by client through its proxy, on the server side, I want
to delete the dll containing the class for the object. But, before
deleting the dll, I have to unload the assembly and .NET does not allow
to unload the assembly(I learnt it from some news group).

*** And you learned wrong. YO ucan delete the assembly as soon as it is
not used anymore, and shadow direcotries can help you with this. With a
Shadow Directory (for the AppDomain) the assemblies (which, BTW., ARE
the dll) are copied to the shadow directory before accessing, so you can
easily remove the dll.

*** THAT SAID - this does not remove the types from memory.

I have tried to unload the assembly by using unmanaged code i.e. by
using win32 library functions such as FreeLibrary. 

*** ARE YOU MAD? You can not just go there, mangle around with the
memory of the runtime and sincerely expect the framework to operate.
What do you do when the image on your scree nis not working? Trying to
pour some water over it, just to see whether the monitor still runs
after drying and putting out the fires?

That serves my purpose only for the first time, next time when I'm
sending again the object and also its dll it's giving exception.

*** Waht do you expect? You killed the library from memory without the
runtime knowing.

Although I have an idea to solve this problem, but I can't apply that
idea. My idea is every time client sends the object by calling server
method I can use differnt appliaction domains to execute the server
method for different call and then unload the appliaction domain. After
unloading the application domain, we can delete the dll.

*** DEPENDING on what types of DLL's you get, this might be your only
way. Remember, even if you delete the assembly, the types stay in
memory. This is going to be a permanent memory hog.

But,how can I write that code? If anybody has any idea please write.

*** Unloading the AppDomain? Simple: restart the server. More complex:
write code that loads the client types (which NEED to be remotable) into
the separate AppDomain.

Thomas

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to