Home Dashboard Directory Help
Search

VSIP: Assembly file handles not being released after AppDomain.Unload by Jamie Cansdale


Status: 

Closed
 as By Design Help for as By Design


1
0
Sign in
to vote
Type: Bug
ID: 536783
Opened: 2/26/2010 5:19:32 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

This happens when executing inside the Visual Studio 2010 process, but not when executing inside the default MSTest process (use the VS SDK's "VS IDE" HostType for repro).

When an assembly is loaded in a new app domain inside Visual Studio 2010, the assembly file handle remains locked after the app domain is unloaded. This appears to happen when the assembly is loaded into the 'Load' context, but not when loaded into the 'LoadFrom' context.

This issue could impact any add-in or package that needs to execute or examine assemblies in an isolated app domain. The most likely symptom is the target project will fail to build until Visual Studio is restarted.
Details
Sign in to post a comment.
Posted by Jamie Cansdale on 2/27/2010 at 9:58 AM
Thanks, this works great!
Posted by Microsoft on 2/26/2010 at 12:55 PM
There was a change made to the default CLR loader optimization behavior used for Visual Studio 2010 (for performance reasons). In 2008 and prior, we used MultiDomainHost loading. In 2010, this was changed to MultiDomain. (You can find more details on this doc topic: http://msdn.microsoft.com/en-us/library/43wc4hhs.aspx).

To get the MultiDomainHost behavior (which will release a file handle on an Assembly when the AppDomain is unloaded), you should set the LoaderOptimization property on the AppDomainSetup object for your AppDomain as follows:

appDomainSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost;

Thank you for taking the time to file a bug report!

Sincerely,
Visual Studio Platform Team
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
AppDomainTests.zip (restricted) 2/26/2010 -