Visual Studio 2013.2 can't build because IIS is locking an assembly

雨燕双飞 提交于 2021-01-27 21:14:39

问题


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"));
        }
    }
}

回答1:


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

Pre-build



来源:https://stackoverflow.com/questions/23727584/visual-studio-2013-2-cant-build-because-iis-is-locking-an-assembly

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