仅在类库输出类型中未找到 Microsoft.WITDataStore32.dll 异常

Posted

技术标签:

【中文标题】仅在类库输出类型中未找到 Microsoft.WITDataStore32.dll 异常【英文标题】:Microsoft.WITDataStore32.dll not found exception only in Class Library output type 【发布时间】:2018-07-09 18:13:46 【问题描述】:

尝试使用Microsoft.TeamFoundationServer.ExtendedClient 15.112.1 https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/

使用 Visual Studio 2017

控制台应用程序中的这段代码运行良好:

string tfsUrl = "tfsurl";
string project = "project";
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(tfsUrl));
ITestManagementService tms = tfs.GetService<ITestManagementService>();
var proj = tms.GetTeamProject(project);

作为单元测试项目一部分的 TestMethod 中的此代码不:

string tfsUrl = "tfsurl";
string project = "project";
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(tfsUrl));
ITestManagementService tms = tfs.GetService<ITestManagementService>();
var proj = tms.GetTeamProject(project);
Assert.IsNotNull(proj);

它在tms.GetTeamProject(project) 上引发异常: System.DllNotFoundException:'无法加载 DLL'Microsoft.WITDataStore32.dll':找不到指定的模块。 (来自 HRESULT 的异常:0x8007007E)'

我尝试过的解决方案:

将 WITDataStore32.dll 复制到 bin 目录

将 WITDataStore32.dll 从 packages\Microsoft.TeamFoundationServer.ExtendedClient.15.112.1\lib\native\x86 文件夹复制到 C:\Windows\System32

将 WITDataStore32.dll 从 packages\Microsoft.TeamFoundationServer.ExtendedClient.15.112.1\lib\native\x86 文件夹复制到 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE 文件夹中

安装 Team Foundation Server TFS 包并将 WITDataStore32.dll 从 C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer 文件夹复制到 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE 文件夹中

到目前为止没有任何效果......

下面的完整堆栈转储:

Result StackTrace:  
at Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.DataStoreNative32.CreateDatastore(IntPtr& handle)
   at Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.DataStoreNative.CreateDatastore(IntPtr& handle)
   at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.InitializeInternal()
   at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.Microsoft.TeamFoundation.Client.ITfsTeamProjectCollectionObject.Initialize(TfsTeamProjectCollection teamProjectCollection)
   at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.InitializeTeamFoundationObject(String fullName, Object instance)
   at Microsoft.TeamFoundation.Client.TfsConnection.CreateServiceInstance(Assembly assembly, String fullName)
   at Microsoft.TeamFoundation.Client.TfsConnection.GetServiceInstance(Type serviceType, Object serviceInstance)
   at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.GetServiceInstance(Type serviceType, Object serviceInstance)
   at Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementTeamProject.GetWitProject()
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementTeamProject.get_WitHelper()
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementTeamProject.get_SharedParameterDataSetWorkItemTypeName()
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementTeamProject.get_HasSupportForSharedParameterDataSets()
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementTeamProject..ctor(TestManagementService manager, String projectName)
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementService.<GetTeamProject>b__0_0(String name)
   at Microsoft.TeamFoundation.TestManagement.Client.ObjectCache`2.Get(Key key, Creator creator)
   at Microsoft.TeamFoundation.TestManagement.Client.TestManagementService.GetTeamProject(String projectName)
   at CodedUITestProject1.CodedUITest1.CodedUITestMethod1() in c:\users\me\source\repos\CodedUITestProject1\CodedUITestProject1\CodedUITest1.cs:line 32
Result Message: 
Test method CodedUITestProject1.CodedUITest1.CodedUITestMethod1 threw exception: 
System.DllNotFoundException: Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

【问题讨论】:

【参考方案1】:

您还需要安装 Microsoft.TeamFoundationServer.Client

然后在创建安装程序时,您需要从输出目录中获取上述文件,将其作为资源(始终复制)添加到您的文件中。否则 Publish 活动将无法识别它,因此执行将失败。

【讨论】:

是的,现在可行的是在项目构建设置中对其进行配置,以手动将文件从本地 nuget 包复制到输出目录中。这样我们就不需要将 .dll 签入源代码管理,它仍然可以在我们的自容器构建服务器上运行。

以上是关于仅在类库输出类型中未找到 Microsoft.WITDataStore32.dll 异常的主要内容,如果未能解决你的问题,请参考以下文章

模板函数替换仅在一个参数中未使用std :: function时才起作用

华硕电脑搜不到无线,连不了无线,microsoft wi-fi direct virtual adapter设备无

Xcode 7 中未找到解析 UI 错误

为啥在使用 Promise 时在类方法中未定义“this”? [复制]

graphql中未定义类型的输出错误

Asp.Net 5 类库中未引用 Mscorlib