问题
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:
来源:https://stackoverflow.com/questions/23727584/visual-studio-2013-2-cant-build-because-iis-is-locking-an-assembly