PC Review


Reply
Thread Tools Rate Thread

After AppDomain.Unload(...) there still a handle exists,...

 
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      9th Mar 2009
Hi,

i am doing the following:

FileStream fsAssembly = File.Open(ExecutablePath,
FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

byte[] AssemblyRAWBytes = new byte[fsAssembly.Length];

fsAssembly.Read(AssemblyRAWBytes, 0, (int)
fsAssembly.Length);
fsAssembly.Close();

DRSHLoaderDomain =
AppDomain.CreateDomain("DRSHLoaderDomain");

Assembly drass = DRSHLoaderDomain.Load(AssemblyRAWBytes);

FileVersionInfo fvi =
FileVersionInfo.GetVersionInfo(ExecutablePath);
AssemblyNameReadOnlyInfo aroi = new
AssemblyNameReadOnlyInfo(drass.GetName());


this.propertyGridDRExeFileProperty.SelectedObject = fvi;
this.propertyGridDRAssemblyDetails.SelectedObject = aroi;

AppDomain.Unload(DRSHLoaderDomain);


This works fine and everything is displayed as expected, ...means that i see
all information
i wanted in the property grids and the AppDomain is unloaded from memory and
context. But when i try to execute the Application pointing in
"ExecutablePath", it
also starts as expected, but when the application want to open itself (mens
the path
in "ExecutablePath") and wants to generate a MD5 Hash by reading itself into
memory, it says that it cant open because the file has been locked. This
only happens
when i execute the code above. I investigated with Process Explorer and
found out
that the Code/App above still holds a File Handle to "ExecutablePath" Path.
I am
not pretty sure, but isnt the AppDomain and all Assemblies, including its
handles, etc
removed/closed from memory by unloading the AppDomain? At least thats what
i think here. I checked by removing all inside that code section above,
except the
domain loading stuff and its really an AppDomain issue,...so what to do now
to
make sure everything is properly closed?

Any Help would be nice,...

Regards

Kerem



--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
appdomain.unload sam.m.gardiner Microsoft Dot NET Framework 3 9th Aug 2007 01:48 PM
appDomain Unload =?Utf-8?B?UmFpbg==?= Microsoft C# .NET 1 30th Jan 2006 08:04 AM
AppDomain / Object Lifetime & AppDomain.Unload =?Utf-8?B?QXJ0aHVyIE0u?= Microsoft Dot NET Framework 1 12th Jul 2005 08:09 PM
AppDomain.Unload Roman Microsoft Dot NET Framework 2 20th May 2004 10:09 AM
unload assembly - AppDomain.Unload does not work as expected =?Utf-8?B?RGllcmsgRHJvdGg=?= Microsoft Dot NET Framework 2 4th Apr 2004 04:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:35 AM.