1
Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The other answers I see regarding this issue say that copying them to the bin directory is the solution. I clearly can see mine in the bin directory. I've uninstalled and reinstalled the TFS extended nuget package, cleaned, rebuilt, etc. just about 50 times now.

This error only occurs at runtime. The solution builds just fine.

Besides burning the whole thing to the ground what are some ways I could resolve this issue?

namespace (mynamespace)
{
    class TFSConnection
    {
        string tfsUrl = "(tfsurl)";
        string project = "(tfsProject)";
        public ITestManagementTeamProject GetProject()
        {
            TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(tfsUrl));
            ITestManagementService tms = tfs.GetService<ITestManagementService>();

            return tms.GetTeamProject(project);
        }
    }
}
Reed
  • 1,515
  • 1
  • 21
  • 38
  • Show the piece of code that's attempting to access this module. – PMF Mar 13 '18 at 14:48
  • @PMF I've added my code above (with sanitizing). It is throwing at the `tms.GetTeamProject()` according to the stack trace. Tracing all the way back to `DataStoreNative32.CreateDatastore(IntPtr& handle)` – Reed Mar 13 '18 at 15:02
  • Which version of TFS are you using? And which version of VS are you using? Including copy the DLL 'Microsoft.WITDataStore32.dll' to the bin folder, you could also try other solution in the following case: https://stackoverflow.com/questions/31031817/unable-to-load-dll-microsoft-witdatastore32-dll-teamfoundation-workitemtracki – Cece Dong - MSFT Mar 14 '18 at 07:10
  • @CeceDong-MSFT TFS 2015 and migrating a project from Visual Studio 2013 to 2015. – Reed Mar 14 '18 at 19:36
  • Is your project working in VS 2013? Which version of TFS extended nuget package did you install? – Cece Dong - MSFT Mar 15 '18 at 08:33
  • @CeceDong-MSFT It works on 2013 fine but the required extended libraries for 2015 do not. This issue in this thread is what I get when using the solution in 2015 with the latest version of the nuget package. – Reed Mar 15 '18 at 17:39
  • How about using TFS extended nuget package 12.0? – Cece Dong - MSFT Mar 16 '18 at 08:08
  • @CeceDong-MSFT That package targets older versions of visual studio does it not? I was told it won't work in 2015 and higher. – Reed Mar 21 '18 at 14:51
  • @Reed Sorry, I mean if you use TFS extended nuget package 14.0 and copy the Microsoft.WITDataStore32.dll to the bin folder as this case describe: https://stackoverflow.com/questions/31031817/unable-to-load-dll-microsoft-witdatastore32-dll-teamfoundation-workitemtracki – Cece Dong - MSFT Mar 23 '18 at 09:28

1 Answers1

0

You can get the given exception even if the indicated file is actually there, but it's dependencies are not. If the package comes with more dlls (which I assume, because it seems to be a C# wrapper somehow), make sure these are also in the bin folder.

Unfortunately, if a native dll is missing, .NET will not tell you which one is missing, but instead return the name of the last managed DLL in the stack trace.

PMF
  • 14,535
  • 3
  • 23
  • 49
  • So how can I find out what dependencies the solution is missing then? – Reed Mar 13 '18 at 16:42
  • There's no easy way to determine that. I remember having a lot of try-until-it-works last time when I had this problem (in an unrelated context). For your particular case, see https://stackoverflow.com/questions/31031817/unable-to-load-dll-microsoft-witdatastore32-dll-teamfoundation-workitemtracki?noredirect=1&lq=1 – PMF Mar 14 '18 at 07:25
  • Yes I have seen that thread but it doesn't apply because the DLL is very clearly in my bin directory. There are over 75 projects in this single solution so trial and error isn't ideal unfortunately. – Reed Mar 14 '18 at 19:35
  • 1
    You might be able to get some more information if you attach the debugger in "mixed" (native) mode. Or use SysInternals Process Monitor to find out which file it tries to open. – PMF Mar 15 '18 at 07:06