msvcp120.dll and msvcr120.dll files breaking my app After nReco.PdfGenerator adds to my bin directory

1

I have an asp.net mvc web application working fine before I upgraded nreco.pdfgenerator to version 1.1.10. After upgrading to version 1.1.10, whenever a pdf file is generated, the application stops working and just displays the message

Server Error in '/' Application.
Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
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.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'file:///C:\Projects\bin\msvcp120.dll' could not be loaded.


=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Projects\bin\msvcp120.dll
LOG: Appbase = file:///C:/Projects/
LOG: Initial PrivatePath = C:\Projects\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Projects\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Projects/bin/msvcp120.dll.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.


Stack Trace:


[BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102
   System.Reflection.Assembly.LoadFrom(String assemblyFile) +34
   WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:11

[InvalidOperationException: The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +613
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9942412
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

I've tried googling the error and found no solution anywhere.

Any help will be very much appreciated.

wkhtmltopdf
msvcr120.dll
asked on Stack Overflow Mar 7, 2016 by Babatunde

1 Answer

1

Not sure how to resolve the error, but I have found a workaround.

Simply set the "PdfToolPath" to a different folder to keep those bad dlls out of bin:

var pdfGenerator = new NReco.PdfGenerator.HtmlToPdfConverter
{
    PdfToolPath = Path.Combine(HttpRuntime.AppDomainAppPath, "PdfTool")
};

This would cause NReco.PdfGenerator to copy the wkhtmltopdf.exe program and the 2 required dlls to the folder "PdfTool" instead.

answered on Stack Overflow Jun 28, 2016 by ryan

User contributions licensed under CC BY-SA 3.0