In our project we are using the following nuget package:
Microsoft.SqlServer.Types
Everything has worked fine until recently without me obviously changing anything important the ASP.NET application breaks when starting with following exception:
Error loading msvcr120.dll (ErrorCode: 5)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Error loading msvcr120.dll (ErrorCode: 5)
The stacktrace:
[Exception: Error loading msvcr120.dll (ErrorCode: 5)]
SqlServerTypes.Utilities.LoadNativeAssembly(String nativeBinaryPath, String assemblyName) in E:\Dev\Jacobo\ServerApi\SqlServerTypes\Loader.cs:43
SqlServerTypes.Utilities.LoadNativeAssemblies(String rootApplicationPath) in E:\Dev\Jacobo\ServerApi\SqlServerTypes\Loader.cs:28
Jacobo.ServerApi.WebApiApplication.Application_Start() in E:\Dev\Jacobo\ServerApi\Global.asax.cs:26[HttpException (0x80004005): Error loading msvcr120.dll (ErrorCode: 5)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +529
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +185
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +421
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +359[HttpException (0x80004005): Error loading msvcr120.dll (ErrorCode: 5)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +534 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +117
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +726
The application breaks in following method:
private static void LoadNativeAssembly(string nativeBinaryPath, string assemblyName)
{
var path = Path.Combine(nativeBinaryPath, assemblyName);
var ptr = LoadLibrary(path);
if (ptr == IntPtr.Zero)
{
throw new Exception(string.Format(
"Error loading {0} (ErrorCode: {1})",
assemblyName,
Marshal.GetLastWin32Error()));
}
}
Which is part of loader.cs which is a part of the SqlServerTypes nuget package.
I checked the bin folder and located the SqlServerTypes assemblies existing there. I am really unsure what has gone wrong here.