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."