3

During testing I want a dll to be picked from a local folder instead of the GAC. As per articles on web and msdn, using DEVPATH is one of the solutions, but it doesn't seem to work. (I don't want to change the version or remove strong name - which are two alternative ways to solve this issue, as per suggestions at various places).

Details: I have ProductCode.dll which is gac-ed. I made some changes to the source code and I want to test that. I have unit tests written in TestCode.dll. However, during testing (I am using vstest.console.exe on command line), the assembly in the gac gets picked up. I want .NET to pick up the assembly in the local folder instead.

I have set DEVPATH environment variable to:

set DEVPATH=C:\temp\NoSysGac\TryingAppDomainsToBypassGac\TestCodeDllAndLatestProductCodeDll

I modified machine.config at C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config to enable development mode:

<runtime>
  <developmentMode developerInstallation="true"/>
</runtime>

Then I run tests using:

C:\Path\to\vstest.console.exe TestCode.dll

But this fails to find the new method I added because it picks up ProductCode.dll from GAC, which is old. I can verify that the modified machine.config does get picked up because the application failed to start when I had a typo in the file. Fusion also recognizes the DEVPATH value, but still doesn't look there. It just returns the assembly from the gac.

Fusion log:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\te.processhost.managed.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = ProductCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6b6a45a9f6fa2e7a
 (Fully-specified)
LOG: Appbase = file:///C:/temp/NoSysGac/TryingAppDomainsToBypassGac/TestCodeDllAndLatestProductCodeDll
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = te.processhost.managed.exe
Calling assembly : TestCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\te.processhost.managed.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ProductCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6b6a45a9f6fa2e7a
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\windows\Microsoft.Net\assembly\GAC_MSIL\ProductCode\v4.0_1.0.0.0__6b6a45a9f6fa2e7a\ProductCode.dll.
LOG: Assembly is loaded in default load context.

Am I missing something obvious here? Or is DEVPATH broken in .NET 4.5 too?

Turbo
  • 2,179
  • 18
  • 38

0 Answers0