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

时间:2018-07-09 18:13:47

标签: c# visual-studio visual-studio-2017

尝试使用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 个答案:

答案 0 :(得分:0)

您还需要安装Microsoft.TeamFoundationServer.Client

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