本文介绍了在VSTS上使用GAC_MSIL程序集时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储在VSTS中的ASP Web表单项目,并且正在尝试构建它.突然我在构建部分遇到了这个错误:

I have an ASP web form Project stored in VSTS, and I am trying to build it. Suddenly I got this error in the build section:

2017-04-18T22:01:20.3859517Z Build FAILED.
2017-04-18T22:01:20.3859517Z
2017-04-18T22:01:20.3869498Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-18T22:01:20.3869498Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default target) (2) ->
2017-04-18T22:01:20.3869498Z (ResolveComReferences target) ->
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "2df8d04c-5bfa-101b-bde5-00aa0044de52" version 2.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "00020813-0000-0000-c000-000000000046" version 1.7. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "00020905-0000-0000-c000-000000000046" version 8.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "0002e157-0000-0000-c000-000000000046" version 5.3. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z
2017-04-18T22:01:20.4149496Z
2017-04-18T22:01:20.4149496Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-18T22:01:20.4149496Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj"     (default target) (2) ->
2017-04-18T22:01:20.4149496Z (CoreCompile target) ->
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(6,17): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(5,17): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(127,104): error CS0246: The type or namespace name 'Worksheet' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(166,80): error CS0246: The type or namespace name 'Worksheet' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(18,17): error CS0246: The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(172,143): error CS0246: The type or namespace name 'Document' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(19,17): error CS0246: The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z
2017-04-18T22:01:20.4149496Z     4 Warning(s)
2017-04-18T22:01:20.4149496Z     7 Error(s)

我正在使用Hosted Queue构建项目.我试图获取程序集的本地副本,将它们包含到项目(/bin)中并上载它们,但是它不起作用.¿如何将它们包含在内部版本中,从而避免出现此错误?

I am using Hosted Queue to build the project. I have tried to get a local copy of the asemblies, include them into the project (/bin) and upload them, but it does not work. ¿How Can I include them into the build so I can avoid this error?

如果我使用Visual Studio Community 2015在本地构建项目,则可以正常工作(参考文件中已经包含了外观).

If I build the project in my local using Visual Studio Community 2015, works fine (the aseemblies are already included in references).

我没有私人代理(仅使用托管).我的构建配置是默认构建.一切都因默认而异.NuGet恢复,.sln根路径,默认的Visual Studio构建以及没有测试程序集.

I have no private agents (just using Hosted). My build configuration was default build. Everythign else by defaul. NuGet restore, .sln root path, default visual studio build and no test assemblies.

对不起,如果我忘了别的东西.

Sorry if I forgot something else.

非常感谢,

推荐答案

好吧,经过一些深入的研究,我终于明白了.我分两步解决了这个问题:

Well, after some in-depth research, I finally got it. I solved it in two steps:

第一步.我已经在** \ bin \文件夹中包含了dll.这些dll是GAC嵌入式程序集的一部分,因此获取它们的方法是参见本文

First Step. I have included the dll's in the **\bin\ folder. These dll's are part of GAC embeded assembly, so the way to get them is See this article

一旦在GAC中部署了DLL(通常位于c:\ windows \ assembly中),就无法将其视为常规DLL文件或将其用作常规DLL文件.无法从VS项目中直接引用它们.开发人员通常保留原始DLL文件的副本,并在开发(设计)时在项目中引用它,该文件在项目运行时使用GAC的程序集.

DLLs once deployed in GAC (normally located at c:\windows\assembly) can’t be viewed or used as a normal DLL file. They can’t be directly referenced from VS project. Developers usually keep a copy of the original DLL file and refer to it in the project at development (design) time, which uses the assembly from GAC during run-time of the project.

在执行过程中(运行时),如果发现程序集已在GAC中签名并部署,CLR会自动从GAC中拾取程序集,而不是在VS中的设计时从中提取DLL.如果开发人员已删除原始DLL或由于某种原因而没有原始DLL,则有一种方法可以从GAC获取DLL文件.请按照以下步骤从GAC复制DLL

During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. Follow the following steps to copy DLL from GAC

  1. 运行regsvr32/u C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ shfusion.dll

  1. Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

  • shfusion.dll是一个资源管理器扩展DLL,它使GAC文件夹具有独特的外观.取消注册该文件将删除程序集缓存查看器,然后GAC文件夹将在资源管理器中显示为任何普通文件夹.

  • shfusion.dll is an explorer extension DLL that gives a distinct look to the GAC folder. Unregistering this file will remove the assembly cache viewer and the GAC folder will be then visible as any normal folder in explorer.

  1. 打开%windir%\ assembly \ GAC_MSIL".
  2. 浏览到DLL文件夹深处以找到您的DLL.
  3. 将DLL复制到硬盘上的某个位置,然后在项目中从那里引用它
  4. 运行"regsvr32%windir%\ Microsoft.NET \ Framework \ \ shfusion.dll"以重新注册shfusion.dll文件并重新获得GAC的原始视图.

或者,您也可以直接通过命令行(CMD)来获取它们

Alternatively you can get them through command line (CMD) directly

之后,我将它们上传到我的项目中.

After that I uploaded them into my project.

第二步.我已经修改了构建过程,添加了测试程序集(** \ bin * .dll).

Second Step. I have modifed my build process adding Test assemblies (**\bin*.dll).

我还从2017年到2015年修改了Visual Studio版本(实际上并没有任何改变).

Also I modifed visual studio version from 2017 to 2015 (which actually does not change anything).

也许有更好的方法,我只是找到了一种解决方法(显然).

Maybe there is a better approach, I have simply found a way to fix it (apparently).

新的VSTS输出日志(FYI)

New VSTS output Log (FYI)

2017-04-19T09:29:15.1691631Z Done Building Project "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default targets).
2017-04-19T09:29:15.1701644Z Done Building Project "d:\a\1\s\WebTimeSheet.sln" (default targets).
2017-04-19T09:29:15.1721645Z
2017-04-19T09:29:15.1721645Z Build succeeded.
2017-04-19T09:29:15.1841654Z
2017-04-19T09:29:15.1841654Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-19T09:29:15.1841654Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default target) (2) ->
2017-04-19T09:29:15.1841654Z (ResolveComReferences target) ->
2017-04-19T09:29:15.1841654Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "2df8d04c-5bfa-101b-bde5-00aa0044de52" version 2.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-19T09:29:15.1841654Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "0002e157-0000-0000-c000-000000000046" version 5.3. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-19T09:29:15.1841654Z
2017-04-19T09:29:15.1841654Z     2 Warning(s)
2017-04-19T09:29:15.1841654Z     0 Error(s)
2017-04-19T09:29:15.1841654Z
2017-04-19T09:29:15.1851621Z Time Elapsed 00:00:10.59
2017-04-19T09:29:15.2201873Z ##[section]Finishing: Build solution

这篇关于在VSTS上使用GAC_MSIL程序集时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:50