Asp.net mvc 5 使用StructureMap时未找到ServiceLocatorImplBase.cs
在Visual Studio(2017)中调试(F5)我的代码时出现以下错误: 找不到ServiceLocatorImplBase.cs 阅读详细信息,它似乎在我的计算机上以下位置查找文件: 'c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs' 我没有目录“c:\Home\Chris…”,我也不知道它为什么会出现在那里 如何解决此问题?(回答自己的问题) 我花了好几天寻找答案 我注意到,在安装StructureMap之后,我开始遇到这个问题。在这个帮助下,我设法解决了这个问题 简而言之,我必须使用NuGet安装CommonServiceLocator v2.0.1。。完成后,我必须更新此文件: StructureMappDependencyScope.csAsp.net mvc 5 使用StructureMap时未找到ServiceLocatorImplBase.cs,asp.net-mvc-5,runtime-error,structuremap,Asp.net Mvc 5,Runtime Error,Structuremap,在Visual Studio(2017)中调试(F5)我的代码时出现以下错误: 找不到ServiceLocatorImplBase.cs 阅读详细信息,它似乎在我的计算机上以下位置查找文件: 'c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs' 我没有目录“c:\Home\Chris…”,我也不知道它为什么会出现在那里 如何解
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web.Http.Dependencies;
//使用Microsoft.Practices.ServiceLocation
使用结构图;
使用CommonServiceLocator;
命名空间UI.DependencyResolution
{
///
///结构映射依赖范围。
///
公共类结构MapDependencyScope:ServiceLocatorImplBase,IDependencyScope
{
我添加了对CommonServiceLocator
的引用,并删除了对Microsoft.Practices.ServiceLocation
的引用
这消除了对c:\Home\Chris…
的硬依赖
希望这能帮助别人
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
{