我的C#/.NET程序编译成了
构建后,在bin\Debug中,我得到了该程序集的32位版本,VS可能从
啊,看起来VS已经将程序集安装到了32位和64位的GAC中,而.NET加载器知道如何加载正确的程序集。 我的问题:如果我无法安装VS,如何模拟这样的行为?
AnyCPU
,并引用了Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
,该dll随Visual Studio(或Team Explorer)一起安装。我的程序必须在没有安装VS的计算机上运行,包括32位和64位,因此我必须将此程序集与我的程序一起使用。它目前可以在32位计算机上运行,但不能在64位计算机上运行,因为它无法加载此程序集。构建后,在bin\Debug中,我得到了该程序集的32位版本,VS可能从
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
获取该版本。这就是程序在32位计算机上运行的方式。但我的程序也在本地以64位运行,并且会加载32位程序集,这是怎么回事呢?为了检查,我写了一个小PowerShell脚本:param([string] $path)
$AssemblyName = [Reflection.Assembly]::Loadfile($path).GetName()
write-output $AssemblyName | fl
并且以32位和64位方式运行:
> powershell.exe -ExecutionPolicy ByPass -f .\f.ps1 Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
(...)
CodeBase : file:///C:/windows/assembly/GAC_64/Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader/11.0.0.0
> C:\Windows\SysWow64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -f .\f.ps1 Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
(...)
CodeBase : file:///C:/windows/assembly/GAC_32/Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader/11.0.0.0__b03f5f7f11d50a3a/Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
啊,看起来VS已经将程序集安装到了32位和64位的GAC中,而.NET加载器知道如何加载正确的程序集。 我的问题:如果我无法安装VS,如何模拟这样的行为?
- 选项1:编译两次,得到32位和64位的二进制文件,然后我猜我会在bin\Debug中得到正确的二进制文件。我不想这样做...
- 选项2:在运行时机器上部署这些32/64位的程序集到GAC中。我希望保持我的部署简单的xcopy...