代码之家  ›  专栏  ›  技术社区  ›  Alex P

ServiceLocatorImplBase。使用StructureMap时未找到cs

  •  3
  • Alex P  · 技术社区  · 7 年前

    在Visual Studio(2017)中调试(F5)我的代码时,我遇到以下错误:

    ServiceLocatorImplBase。未找到cs

    阅读详细信息,它似乎在我的计算机上以下位置查找文件:

    c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft。实践。ServiceLocation\ServiceLocatorImplBase。cs'

    我没有目录 'c:\Home\Chris…' 我不知道为什么它会出现在那里。

    我怎样才能解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  12
  •   Alex P    7 年前

    (回答自己的问题)

    我花了几天时间寻找答案。

    我注意到,在安装StructureMap之后,我开始出现这个问题。在这个帮助下,我设法解决了这个问题 explanation.

    简而言之,我必须安装 CommonServiceLocator v2.0.1。 使用NuGet。一旦我这样做了,我就必须更新这个文件:

    StructureMapDependencyScope。反恐精英

    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... .

    希望这能帮助别人。