ServiceLocatorImplBase.cs 使用 StructureMap 时未找到
ServiceLocatorImplBase.cs not found when using StructureMap
我在 Visual Studio (2017) 中调试 (F5) 代码时出现以下错误:
ServiceLocatorImplBase.cs not found
阅读详细信息,它似乎在我的计算机上的以下位置寻找文件:
'c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs'
我没有目录 'c:\Home\Chris...' 并且我不知道为什么它会在那里查找。
我该如何解决这个问题?
(回答自己的问题)
我花了几天时间寻找答案。
我注意到我在安装 StructureMap 后开始遇到这个问题。我在 explanation.
的帮助下设法解决了这个问题
简而言之,我必须使用 NuGet 安装 CommonServiceLocator v2.0.1.。一旦我这样做了,我就必须更新这个文件:
StructureMapDependencyScope.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Dependencies;
//using Microsoft.Practices.ServiceLocation
using StructureMap;
using CommonServiceLocator;
namespace UI.DependencyResolution
{
/// <summary>
/// The structure map dependency scope.
/// </summary>
public class StructureMapDependencyScope : ServiceLocatorImplBase, IDependencyScope
{
我添加了对 CommonServiceLocator
的引用并删除了对 Microsoft.Practices.ServiceLocation
的引用。
这消除了对 c:\Home\Chris...
的硬依赖。
希望对别人有所帮助。
我在 Visual Studio (2017) 中调试 (F5) 代码时出现以下错误:
ServiceLocatorImplBase.cs not found
阅读详细信息,它似乎在我的计算机上的以下位置寻找文件:
'c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs'
我没有目录 'c:\Home\Chris...' 并且我不知道为什么它会在那里查找。
我该如何解决这个问题?
(回答自己的问题)
我花了几天时间寻找答案。
我注意到我在安装 StructureMap 后开始遇到这个问题。我在 explanation.
的帮助下设法解决了这个问题简而言之,我必须使用 NuGet 安装 CommonServiceLocator v2.0.1.。一旦我这样做了,我就必须更新这个文件:
StructureMapDependencyScope.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Dependencies;
//using Microsoft.Practices.ServiceLocation
using StructureMap;
using CommonServiceLocator;
namespace UI.DependencyResolution
{
/// <summary>
/// The structure map dependency scope.
/// </summary>
public class StructureMapDependencyScope : ServiceLocatorImplBase, IDependencyScope
{
我添加了对 CommonServiceLocator
的引用并删除了对 Microsoft.Practices.ServiceLocation
的引用。
这消除了对 c:\Home\Chris...
的硬依赖。
希望对别人有所帮助。