I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is called, this action will return the model as a view as a PDF.
I have no need to save it locally, just to show it in the browser so that the user can download it.
There is no need for a database either, that is why I store the model in the cache.
Locally, on Visual studio 2013, it works fine. But when I publish it to IIS 7 I get an Unhandled Execution Error. Here is the stack trace that I get back:
Unhandled Execution Error
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:
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.
Stack Trace:
[Exception]
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) +1364
Rotativa.WkhtmltopdfDriver.ConvertHtml(String wkhtmltopdfPath, String switches, String html) +70
Rotativa.ViewAsPdf.CallTheDriver(ControllerContext context) +1986
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +380
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +69
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248
I first used ActionAsPDF() but now I also tried to use return new ViewAsPDF(). Both give the same error and stack trace. Does this have to do something with permissions?
This error is a missing C++ redistributable Package for Visual Studio 2013 file called (MSVCP120.dll).
To solve the issue:
Open the C++ redistributable Package for Visual Studio 2013 downloadable link below:
download Visual C++ Redistributable Packages for Visual Studio 2013
Click Download and choose the file (vcredist_x86.exe) even if you are running X64 bit server version.
Install the file.
Check Jalal W Hijazi Blog http://jwhijazi.blogspot.com/2015/05/solving-rotativa-unhandled-exception.html for more details.
As mentioned in the comments on the blog linked in the answer, you can just copy the 2 following dll files to the rotativa folder on the server if you don't want to / can't easily install things on the server.
msvcr120.dll
msvcp120.dll
If it's working locally, you should have the two dll files available already.
You need the x86 versions, if you find x64 versions packaged with vs 2015 they don't work. I found the right versions here:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT
After upgrading to Rotativa 1.7.3 this no longer worked. I had to copy over some new dlls from visual studio 2017, i found them here this time:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
and i had to copy over
msvcp140.dll
vcruntime140.dll
The accepted answer almost worked for me. I was missing a newer version of the C++ redistributable so installing the old version didn't help.
The easiest way to find out what you are missing is to run wkhtmltopdf.exe manually. It will either give you console output (if working) or a message box about what's missing.
I was missing MSVCP140.dll, which is from the VS 2015 redist, available here: https://www.microsoft.com/en-gb/download/details.aspx?id=48145
I fixed my issue by updating the wkhtmltopdf files from the installer found here
Working flawlessly now!
When I upgraded from Rotativa 1.6.4 to 1.7.3 my PDF conversion on my website app stopped working and after running the wkhtmltopdf.exe on my production server I noticed it was having an issue with msvcp140.dll
Solution was to install Visual C++ Redistributable for Visual Studio 2015
https://www.microsoft.com/en-us/download/details.aspx?id=48145
I faced the same problem. Even the error logger wasn't logging anything.
After some research, I tried replacing the wkhtmltopdf.exe with the latest version available in wkhtmltopdf.org website, still no luck.
Finally copied msvcp120.dll and msvcr120.dll to the folder where I had the excutable and it worked. (There was no need of the latest version of wkhtmltopdf.exe, instead it worked with the version what I got from Nuget.)
msvcp120.dll and msvcr120.dll were available in the below directory in Windows 7.
C:\Windows\SysWOW64\
I installed Visual C ++ Redistributable Packages for Visual Studio 2015
https://www.microsoft.com/pt-br/download/details.aspx?id=48145
This solved for me.
Related
I found this error after publishing the site on the server.
I tried a lot to solve this problem from my side but nothing works for me.
I have tried to update all those packages with the latest and still does not work for me.
But, it works well when I run a project in Visual Studio without any problems.
I have checked these 2 links to fix my problem but it still doesn't work for me.
Specified Web Pages version “3.0.0.0” could not be found. Update your web.config to specify a different version. Current version: “2.0.0.0”
Update your web.config to specify a different version?
However, I tried to install the downgraded (older) version and I got a 404 error code, the resource could not be found.
Also, I have checked all the web config files where the version has been declared and it seems right for me.
I don't know what I should do with this error message.
It would be nice if someone could help me with this.
Server Error in '/' Application.
Specified Web Pages version "3.0.0.0" could not be found. Update your web.config to specify a different version. Current version: "2.0.0.0".
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.InvalidOperationException: Specified Web Pages version "3.0.0.0" could not be found. Update your web.config to specify a different version. Current version: "2.0.0.0".
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.
Stack Trace:
[InvalidOperationException: Specified Web Pages version "3.0.0.0" could not be found. Update your web.config to specify a different version. Current version: "2.0.0.0".]
System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore(IFileSystem fileSystem, String appDomainAppPath, String binDirectory, NameValueCollection appSettings, IEnumerable1 loadedAssemblies, IBuildManager buildManager, Action1 loadWebPages, Action registerForChangeNotification, Func`2 getAssemblyNameThunk) +21268
System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore() +245
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Specified Web Pages version "3.0.0.0" could not be found. Update your web.config to specify a different version. Current version: "2.0.0.0"..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures) +890
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +167
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
System.Web.Compilation.BuildManager.ExecutePreAppStart() +178
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +746
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Specified Web Pages version "3.0.0.0" could not be found. Update your web.config to specify a different version. Current version: "2.0.0.0"..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0
My .net project (Any CPU) is referring to Oracle.dataaccess x86 version . In my local GAC the odac version is x86. But in the web server where it was installed previously was having AMB64 version of odac in GAC . The site was working without any problem . Now I need to move the site to AWS .The windows instance in AWS has the below configuration.
OS version : Microsoft windows server 2012 R2 Standard .
IIS 8.5
The server is clean and does not have any software installed .
When I try to create a site , I ended up seeing **could not load file or assembly one of its dependencies **. Through forums I installed various libraries from Oracle but I don't understand what are the exact steps needed . I was just doing trial and error.
Please let me know the software or steps to follow which needs do be installed such that my .net site which is connecting to its Oracle database works .
Edit 1 :
Hi ,
I performed the following steps .
As suggested by you I added Oracle.managedDataaccess dll(x86) . It worked well in my local.
Deployed the same code in the server.
I installed the oracle_12.1.0.1.0
In C:/oracle_12.1.0.1.0/odp.net/managed/x86 I ran the bat file for configuring the managed odac in the server. I was able to see the changes in the machine.config file .
5.Now when I ran the site I got the below error .
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.TypeInitializationException: The type initializer for
'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
---> System.DllNotFoundException: Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT:
0x8007007E) at
Oracle.DataAccess.Client.OpsInit.CheckVersionCompatibility(String
version) at Oracle.DataAccess.Client.OracleInit.Initialize() at
Oracle.DataAccess.Client.OracleClientFactory..cctor() --- End of
inner exception stack trace --- --- End of inner exception stack
trace --- at System.RuntimeFieldHandle.GetValue(RtFieldInfo field,
Object instance, RuntimeType fieldType, RuntimeType declaringType,
Boolean& domainInitialized) at
System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) at
System.Reflection.RtFieldInfo.GetValue(Object obj) at
System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
In order to fix this I added OraOps12 dll from c:/oracle_12.1.0.1.0/bin to the wwwroot/site/bin folder. Then I got the below error .
System.ArgumentException: Unable to find the requested .Net Framework
Data Provider. It may not be installed. at
System.Data.Common.DbProviderFactories.GetFactory(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
Checking to resolve this .
Appreciate your suggestions.
After upgrading to Visual Studio 2012 I can no longer access any of my ApiControllers, the following error is thrown:
Server Error in '/' Application.
Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1<System.String>)'.
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.MissingMethodException: Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1<System.String>)'.
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.
Stack Trace:
[MissingMethodException: Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1<System.String>)'.]
System.Web.Http.WebHost.HttpControllerHandler.AddHeaderToHttpRequestMessage(HttpRequestMessage httpRequestMessage, String headerName, String[] headerValues) +0
System.Web.Http.WebHost.HttpControllerHandler.ConvertRequest(HttpContextBase httpContextBase) +248
System.Web.Http.WebHost.HttpControllerHandler.BeginProcessRequest(HttpContextBase httpContextBase, AsyncCallback callback, Object state) +79
System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +268
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17626
Anyone knows how to fix this?
You have a reference to an old version of System.Net.Http in your project. To fix this, go under "References" in your project, delete System.Net.Http, and add the version that comes with .NET 4.5 instead. That should do it.
Henrik
Solution to this and other RC-related issues right here.
step 1
Remove the below references from your project:
System.Net.Http, System.Web.Http, System.Web.Http.WebHost , System.Web.Http.Common & System.Net.Http.Formatting
step 2
Add the above refefrences (except the System.Web.Http.Common & System.Net.Http.Formatting) from Below location
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.WebApi.Core.4.0.20505.0\lib\net40
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.AspNet.WebApi.WebHost.4.0.20505.0\lib\net40
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.Net.Http.2.0.20505.0\lib\net40
and add one more new dll Newtonsoft.Json.dll from
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Newtonsoft.Json.4.5.1\lib\net40
This fixed it for me.
http://forums.asp.net/t/1809919.aspx/1
Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1)'.
I resolved it with the following steps. Not sure if all of them are required, but it worked.
In NuGet Package Manager, uninstalled the Web.API Beta package.
Added references to System.Net.Http, System.Web.Http, & System.Web.Http.WebHost (these were removed by the previous step).
Installed Json.Net via NuGet.
As an addition, if your project is targeting the 4.0 version of the framework, you must include the new Microsoft ASP.Net Web API set of packages from NUGET, to get a green light for your build. Json.Net is a dependency for these new packages, so you need not install it separate.
Using .Net framework 4. I am assuming this log4net version that the PayPal library is dependent on
requires an older version or I don't have the file at all? Do I need to get this file somewhere or
is there another work around ?
Update, after installing latest version of log4net I now get the same error except the file is found
this time and says**:
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
com.paypal.sdk.profiles.BaseAPIProfile..cctor() +0
Line 23: {
Line 24: NVPCallerServices caller = new NVPCallerServices();
Line 25: **IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();**
code.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.0.30714, Culture=neutral, PublicKeyToken=b32731d11ce58905' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.]
com.paypal.sdk.profiles.BaseAPIProfile..cctor() +0
[TypeInitializationException: The type initializer for 'com.paypal.sdk.profiles.BaseAPIProfile' threw an exception.]
com.paypal.sdk.profiles.BaseAPIProfile..ctor() +0
com.paypal.sdk.profiles.SignatureAPIProfile..ctor() +29
com.paypal.sdk.profiles.ProfileFactory.createSignatureAPIProfile() +39
GenerateCodeNVP.ECSetExpressCheckout.ECSetExpressCheckoutCode(String returnURL, String cancelURL, String amount, String paymentType, String currencyCode) in C:\Users\Admin\Documents\Visual Studio 2010\Projects\MyProject\DotNetNVPGenerate\ECSetExpressCheckout.cs:25
NeoCart.WebUI.Controllers.CheckoutController.Payment() in C:\Users\Admin\Documents\Visual Studio 2010\Projects\MyProject\NeoCart.WebUI\Controllers\CheckoutController.cs:179
lambda_method(Closure , ControllerBase , Object[] ) +96
Log4net is a separate open-source project.
You can get it from within Visual Studio using NuGet, or you can download it from Apache's website.
This question is a little old, but wanted to let you know, I was having the same issue, and found the proper library for this issue. You'll want to go to the Beta 8 archive for the sourceforge project here: http://sourceforge.net/projects/log4net/files/log4net/1.2.0%20Beta8/
Download this repository, and look in log4net-1.2.0-beta8\log4net-1.2.0-beta8\bin\net\1.0\release, the log4net.dll has the version 1.2.0.30714
Even if you don't use this, someone else might run into this question, and hopefully this response will help fix the issue for anyone else.
If I run this command on my system
<Exec Command="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler -v localhost -p $(SourceDir)\wwwroot -u -f projectCompileCode\project -c -errorstack -nologo" />
I get the following error:
error ASPParse: Could not load the type: Projectname:SomeFile.
The project is web application project
This my stack trace:
[HttpException]: Could not load type 'ProjectName.FileName'.
at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCa
e, Boolean throwOnError)
at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeN
me, String codeFileBaseTypeName, String src, Assembly assembly)
at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDicti
nary parseData)
[HttpParseException]: Could not load type ''ProjectName.FileName.
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virt
alPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseReader(StreamReader reader, VirtualP
th virtualPath)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPat
virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType(
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(
uildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResu
t(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath
tartingVirtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath starting
irtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCa
lback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManag
rCallback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManag
rCallback callback)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(Client
uildManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(Client
uildManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
If I build in v2.0.50727 then still it is giving the same error.
My application is built in with VS 2010, .net frame asp.net frame work 4
Any help is greatly apperciated.
Have you tried:
Checking references
Doing a clean and a build
Checking the Inherits attr in the HTML against the code behind
Creating a new App Pool in IIS for this web site?
I see a similar problem. Works locally from within VS2008, but once published and deployed to the server, I get the same error as described here.
None of the suggestions I have provided worked for me; maybe they will work for you.
I had the same error. When I opened the web site DLL in ILDASM, the Type for a control was completely missing, as if it didn't even get compiled.
As it turns out, the codebehind files got excluded from the project. This is strange considering that the builds on my machine were successful! At any rate, I carefully re-included codebehind files and it all started working.
This often happens because the project file (.csproj or .vbproj) does not contain the necessary references to the files in question. Try cleaning/rebuilding all projects and making sure that the latest project files are moved to the server as well.
Another possibility is that the file was not actually included in your project at all. This allows the builds in Visual Studio to run just fine, but will break when compiling the .NET code (with aspnet_compiler for example) because all .aspx/.ascx/etc. files within the specified folder are compiled - whether they are included in your project or not.