DllNotFoundException in ASP5/MVC6 while instantiating an object (using the WorkItemStore Class)

有些话、适合烂在心里 提交于 2019-12-10 19:36:16

问题


I'm trying to instantiate the WorkItemStore Class in my MVC 6 (dnx 4.5) web app but I'm getting the following DllNotFoundException error.

An exception of type 'System.DllNotFoundException' occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll but was not handled in user code

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

This is my code.

        200Uri = new Uri("http://x contains tfs server link of company x");
        200ProjectCollection = new TfsTeamProjectCollection(200Uri);
        200WorkItemStore = new WorkItemStore(200ProjectCollection);

The more amazing thing is that the same class and code works on my previous ASP 4.5 Windows Forms app. Is this a problem with Dot Net Core? I've already switched to dnx 4.5.1 in dot net core? or MVC 6? Is this a problem with 32-64 bits library?

More details about the error-

System.DllNotFoundException - {"Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}
Data - {System.Collections.ListDictionaryInternal}
HelpLink - Null
InnerException - null
Message - Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source: Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader
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.WorkItemTracking.Client.WorkItemStore..ctor(TfsTeamProjectCollection teamProjectCollection, WorkItemStoreFlags workItemStoreFlags)
   at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore..ctor(TfsTeamProjectCollection teamProjectCollection)
   at FinalApp1.Models.Config..ctor() in C:\Users\eashan\Documents\Building a Web App using ASP 5\FinalApp1\src\FinalApp1\Models\Config.cs:line 23

TargetSite - {Void CreateDatastore(IntPtr ByRef)}
TypeName - ""

Any kind of help will be appreciated.


回答1:


Use NuGet

  1. Open the NuGet Package Manager.
  2. Go to Browse.
  3. Install Microsoft.TeamFoundationServer.ExtendedClient.
  4. Install Microsoft.WindowsAzure.ConfigurationManager.

Here is the resultant project.json file (with sections deleted for clarity.)

{ 
  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.TeamFoundationServer.ExtendedClient": "14.89.0",
    "Microsoft.WindowsAzure.ConfigurationManager": "3.2.1"
  }

  "frameworks": {
    "dnx451": { }
  }
}

After installing those two packages, the following code builds and runs.

var xUri = new Uri("http://www.somedomain.com");
var xProjectCollection = new TfsTeamProjectCollection(xUri);
var xWorkItemStore = new WorkItemStore(xProjectCollection);



回答2:


For now, I've managed to get it to work.I compared the build paths of my windows application form and my dnx execution environment.

Having checked the Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll library using ILSpy, I found out that it did reference the Microsoft.WITDataStore32.dll, which even though was present in the dnx execution folder

C:\Users\eashan.dnx\packages\Microsoft.TeamFoundationServer.ExtendedClient\14.89.0\lib\native\x86

It did not exist in

C:\Users\eashan.dnx\packages\Microsoft.TeamFoundationServer.ExtendedClient\14.89.0\lib\net45 folder.

So, I copied the library from the first location to the other and it worked.



来源:https://stackoverflow.com/questions/36135155/dllnotfoundexception-in-asp5-mvc6-while-instantiating-an-object-using-the-worki

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!