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 / New Users / July 2006

Tip: Looking for answers? Try searching our database.

CheckIfInstallable method locks the file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stefano - 05 Jul 2006 00:08 GMT
Hi all,
when I try to use the CheckIfInstallable  method of
System.Configuration.Install.AssemblyInstaller on a file not installable, I
correctly get an exception, but then the file checked remains locked by the
application until I close the program (e.g. I can't delete the file or
overwrite it).

Why the file remains locked? Is there a way to avoid it?
Greg Young - 05 Jul 2006 00:21 GMT
It is because Assembly.Load is run on the file (the assembly gets loaded
into your appdomain).

You can see this in the Path setter it uses

     set
     {
           if (value == null)
           {
                 this.assembly = null;
           }
           this.assembly = Assembly.LoadFrom(value);
     }

This will hold a lock on the file until the appdomain is killed.

No way to work around this I'm afraid except to wait until the appdomain is
dead to delete the file.
Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

> Hi all,
> when I try to use the CheckIfInstallable  method of
[quoted text clipped - 4 lines]
>
> Why the file remains locked? Is there a way to avoid it?
Greg Young - 05 Jul 2006 00:26 GMT
I would put this up as a suggestion

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

> It is because Assembly.Load is run on the file (the assembly gets loaded
> into your appdomain).
[quoted text clipped - 28 lines]
>>
>> Why the file remains locked? Is there a way to avoid it?
Damien - 05 Jul 2006 07:51 GMT
> It is because Assembly.Load is run on the file (the assembly gets loaded
> into your appdomain).
[quoted text clipped - 14 lines]
> No way to work around this I'm afraid except to wait until the appdomain is
> dead to delete the file.

So, to help the OP, he could:
1) Create a second AppDomain
2) Load either his existing code assembly or just a simple stub one in
3) Create a class in the second domain
4) Call a method on that class which performs the original
CheckIfInstallable check and returns a boolean
5) Unload the second AppDomain

correct?

Damien
Stefano - 05 Jul 2006 10:09 GMT
Ok, thanks to everybody, I've called the method from a second AppDomain and
everything worked!

>> It is because Assembly.Load is run on the file (the assembly gets loaded
>> into your appdomain).
[quoted text clipped - 27 lines]
>
> Damien

Rate this thread:







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.