Reed
Reed

Reputation: 1642

Microsoft.WITDataStore32.dll not found exception only in Class Library output type

Attempting to use Microsoft.TeamFoundationServer.ExtendedClient 15.112.1 https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/

Using Visual Studio 2017

This code in a console app works just fine:

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

This code in a TestMethod as part of a Unit Test project does not:

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);

It throws an exception on the tms.GetTeamProject(project): System.DllNotFoundException: 'Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

Solutions I have tried:

Nothing has worked so far...

Full stack dump below:

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)

Upvotes: 0

Views: 720

Answers (1)

Peter Stevens
Peter Stevens

Reputation: 29

You also need to install Microsoft.TeamFoundationServer.Client

Then when creating an installer, then you need to take the file above from the output directory, add it as a resource (copy always) to your file. The Publish activity will otherwise not recognize it, and thus the execution will fail.

Upvotes: 0

Related Questions