由于IIS锁定了程序集,因此无法生成Visual Studio 2013.2 [英] Visual Studio 2013.2 can't build because IIS is locking an assembly

查看:93
本文介绍了由于IIS锁定了程序集,因此无法生成Visual Studio 2013.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET MVC 5应用程序使用的是本地IIS(Windows 7),在我不得不开始使用Microsoft.SqlServer.Types NuGet程序包之前,它一直运行良好.由于该程序包具有本机程序集,因此必须在运行时进行特殊加载.

我遇到的问题是,在重建应用程序并通过浏览器访问它之后,IIS将加载并锁定本机程序集.如果我进行更改并再次重建,Visual Studio会失败,并说程序集已被另一个进程IIS锁定.我发现的唯一解决方法是在构建之前继续重新启动IIS,这在我可能一天必须重新构建数百或数千次(取决于我进行了多少更改)时是不切实际的.

是否有更适当的解决方法?像告诉Visual Studio不要打扰本机程序集吗?帮助将不胜感激.

这是我如何加载程序集:

  [程序集:WebActivatorEx.PreApplicationStartMethod(typeof(X.Mvc.App_Start.SqlServerTypesConfiguration),"LoadAssemblies")]命名空间X.Mvc.App_Start {公共静态类SqlServerTypesConfiguration {公共静态void LoadAssemblies(){SqlServerTypes.Utilities.LoadNativeAssemblies(System.Web.Hosting.HostingEnvironment.MapPath(〜/bin"));}}} 

解决方案

根据评论-我的建议是将 iis_reset 命令放在解决方案的预构建配置步骤下:

My ASP.NET MVC 5 application is using my local IIS (Windows 7) which worked great until I had to start using the Microsoft.SqlServer.Types NuGet package. Because the package has native assemblies they have to be specialty loaded at runtime.

The problem I'm running into though is that after I rebuild the application and access it through the browser IIS loads and locks the native assemblies. If I make the change and rebuild again, Visual Studio fails and says the assemblies are locked by another process, IIS. The only work around I've found is to keep restarting IIS before I build which is unpractical when I may have to rebuild hundreds or thousands of times in a day depending on how many changes I make.

Is there a more proper work around? Like telling Visual Studio not to bother with the native assemblies? Help would be appreciated.

Here's how I'm loading the assemblies:

[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(X.Mvc.App_Start.SqlServerTypesConfiguration), "LoadAssemblies")]

namespace X.Mvc.App_Start {
    public static class SqlServerTypesConfiguration {
        public static void LoadAssemblies() {
            SqlServerTypes.Utilities.LoadNativeAssemblies(System.Web.Hosting.HostingEnvironment.MapPath("~/bin"));
        }
    }
}

解决方案

As per the comment - my suggestion is to put an iis_reset command under the pre-build configuration step of your solution:

这篇关于由于IIS锁定了程序集,因此无法生成Visual Studio 2013.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆