Please I need your help on this issue that I'm facing since 2 days now.
I'm using Rotativa.AspNetCore to export view in pdf with asp.net core 5, my code is working fine from visual studio 2019 but when I publish the app I'm getting this error:
Error. An error occurred while processing your request. Request ID:
00-4b8009f0978a2748b2467f7601bf7758-4639da00167d8849-00
Development Mode Swapping to Development environment will display more
detailed information about the error that occurred. The Development
environment shouldn't be enabled for deployed applications. It can
result in displaying sensitive information from exceptions to end
users. For local debugging, enable the Development environment by
setting the ASPNETCORE_ENVIRONMENT environment variable to
Development and restarting the app.
here is my code:
public async Task<IActionResult> RibExport(string account)
{
rib_pdf rib = new rib_pdf();
var pdf = new ViewAsPdf()
{
ViewName = "RibExport",
FileName = "Rib.pdf",
Model = rib,
PageHeight = 200,
PageOrientation = Rotativa.AspNetCore.Options.Orientation.Landscape,
};
return pdf
}
I'm populating my rib model from my code for the contents.
I can't see any error from my logs files.
I do have:
wkhtmltoimage.exe
wkhtmltopdf.exe
from rotativa folder.
It seems is related with the IIS application pool identity permission issue. I suggest you could firstly set it as system to see if it could resolve this issue.
Like below:
If this has solved your issue, then you could run process monitor to see which permission is needed for accessing the temp folder, after checking it, you could modify the default identity provider IIS APPPOOL\DefaultAppPool's permission to solve this issue
Related
UPDATE
Now, after trying to use EWS as an alternative I've been getting this new error message that I can't seem to fix :
DTD is prohibited in this XML document.
And yes I've given these code a try :
Dim settings As XmlReaderSettings = New XmlReaderSettings()
settings.XmlResolver = Nothing
settings.DtdProcessing = DtdProcessing.Parse
settings.ValidationType = ValidationType.DTD
Dim reader As XmlReader = XmlReader.Create(".xml", settings)
But it made no difference. Please Help!!
For your information : I'm trying to make this to run in a web based version
My code works perfectly during execution to read email using VB.NET.
Unfortunately this happen :
"Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
Additional Info:
I'm a company worker = email I want to retrieve is using company
domain (eg: ...#company.com)
Windows 10
Microsoft Outlook 2016
Visual Studio 2012
.NET framework 4.5.1 & 4.5.2
I code it using Microsoft.Office.Interop
I've searched google for solution on how to handle the problem and so far no luck.
I've tried modifying DCOM
I want to download new security update from support.microsoft, but no luck with the company internet restriction
Please help. I've been stuck for almost a month on this problem
Most likely this happens if Outlook and your app are running in different security contexts (e.g. one app is running as an admin). Try to close Outlook before starting your app - if that works, you have mismatched security context.
Also keep in mind that Office apps (including Outlook) cannot run in a service (such as IIS).
I need your opinion on this: Is it possible to use enterprise library logging dll in the setup project?
Here's what I did:
I created a setup project which will call a windows form to install the database. When I installed the project, it did call the windows form. However, when I click on the "Install" button, it seems that there's a problem and I don't know where it is. Then another popup message is displayed which said that it cannot locate the logging configuration.
But the config file for the windows form is there which includes the configuration for the logging dll. I don't have any idea where to look into.
Please help me with this?
Below is the error message:
UPDATE
I observed that when I run the exe file as is, the enterprise library logging config works. But with the setup project, it does not look for it. Any help on this?
Below is the code for this:
[RunInstaller(true)]
public partial class IPWInstaller : Installer
{
public IPWInstaller()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string targetPath = Context.Parameters["TargetDir"];
InstallDatabase db = new InstallDatabase(targetPath);
DialogResult dbResult = db.ShowDialog();
if (dbResult != DialogResult.OK)
{
throw new InstallException("Database is not installed.");
}
ConfigureFiles config = new ConfigureFiles(targetPath);
DialogResult configResult = config.ShowDialog();
if (configResult != DialogResult.OK)
{
throw new InstallException("Config files are not saved correctly.");
}
}
}
LATEST UPDATE:
I tried to set the value of a certain configuration to my messagebox. This is the result of it when I run the install project.
Is there a way to call my app.config in the setup project
There are at least a couple of things that can go wrong.
The app is not running as it would if you ran it as an interactive user. It is being called from an msiexec.exe process that knows nothing about your intended environment, such as working directory. None of the automatic things that happen because you run from an explorer shell will happen. Any paths you use need to be full and explicit. I think you may need to explicitly load your settings file.
Something else that can happen in a per machine install is that custom actions run with the system account so any code which assumes you have access to databases, user profile items like folders can fail.
Another problem is that Windows Forms often don't work well when called from a VS custom action. It's not something that works very well because that environment is not the STA threading model that is required for window messages etc.
In general it's better to run these config programs after the install the first time the app starts because then you are in a normal environment, debugging and testing is straightforward, and if the db gets lost the user could run the program again to recreate it instead of uninstalling and reinstalling the setup.
I am facing the above problem. I have some piece of legacy code which creates pdf. This code runs on server but on my pc i am getting exception.
The piece of code that give me the exception is:
IPdfManager objPDFTarget = (IPdfManager)Server.CreateObject("Persits.Pdf");
And the exception is
Could not create an object of type 'Persits.Pdf'.
I have tryied
IPdfManager objPDFTarget = new PdfManager();
Blows
Type ExcelType = Type.GetTypeFromProgID("AcroPDF.PDF");
object ExcelInst = Activator.CreateInstance(ExcelType);
ExcelType.InvokeMember("Visible", BindingFlags.SetProperty, null,
ExcelInst, new object[1] { true });
IPdfManager objPDFTarget = (IPdfManager)ExcelInst;
Blows
I have published on my local iis and i have given full access to IIS_IUSR but nothing.
Is web applications using asp.net, .net 3.5 framework.
I will appreciate any help.
Finally i found that in order to debug this piece of code i must have installed aspPdf setup with a key and only the dll was not enough.
Spent several hours today trying to write some unit tests against an ASP.NET project. It's Visual Studio 2010.
Using Windows 7 Enterprise with IIS7.
Steps I took were:
Added a new test project to the solution
Opened a class file as part of the web site (Member.vb)
Right clicked within the class file and "Generate unit tests"
Select the methods I wish to generate stubs for, choose to add to my test project, click OK
Open up the generated MemberTest.vb file in the test project, click within one of the generated tests, click "Run tests in curent context"
When following these precise steps on my Windows XP Professional with IIS6 machine it works fine.
However on the Windows 7 Enterprise machine on IIS7 I get:
The URL specified ('http://localhost/MyProject') does not
correspond to a valid directory. Tests configured to run in ASP.NET in
IIS require a valid directory to exist for the URL. The URL may be
invalid or may not point to a valid Web application.
So what's going on, I can confirm I can browse to http://localhost/MyProject and it displays perfectly.
I feel sure I'm missing some sort of config in Windows/IIS but I'm really at a loss.
Generated test method:
<TestMethod(), _
HostType("ASP.NET"), _
UrlToTest("http://localhost/MyProject")> _
Public Sub MyMethodTest()
Dim target As Member_Accessor = New Member_Accessor() ' TODO: Initialize to an appropriate value
Dim CurrentVal As Short = 0 ' TODO: Initialize to an appropriate value
Dim expected As Short = 0 ' TODO: Initialize to an appropriate value
Dim actual As Short
actual = target.MyMethod(CurrentVal)
Assert.AreEqual(expected, actual)
Assert.Inconclusive("Verify the correctness of this test method.")
End Sub
(Cross-posted at ASP.NET Forums)
This could be a permissions issue.
If you're using the default directory (C:\users\\Documents\Visual Studio 2010\Projects), the app identity pool does not have permissions there. You'd have to create a project in something like C:\webs and make sure app pool identity has permission to the folder.
Refer to Rick Anderson's blog post at http://blogs.msdn.com/b/rickandy/archive/2011/04/22/test-you-asp-net-mvc-or-webforms-application-on-iis-7-in-30-seconds.aspx and see if that helps.
If you have not done unit testing before, I would really recommend that you start by just testing the functionality of your classes as cleanly as possible. Try to break you you functionality into small pieces that can be tested individually without and dependencies to the web context.
Have a look at this question for an idea about What is unit testing
Here is an MSDN Magazine article about testing
You can also have a look at this Blog. The examples are using NUnit but the principal is the same if you are using MSTest.
I can also recommend Roy Osheroves Book Art of unit testing
In you case if the Member class does not have dependencies to web context you don't need the IIS and could instead just do something like this:
<TestMethod()> _
Public Sub MyMethodTest()
Dim target = New Member()
Dim CurrentVal As Short = 0 ' TODO: Initialize to an appropriate value
Dim expected As Short = 0 ' TODO: Initialize to an appropriate value
Dim actual As Short
actual = member.MyMethod(CurrentVal)
Assert.AreEqual(expected, actual)
End Sub
I ran into the same problem today. After some research, I found this thread which suggested I check my event log. Upon doing that, I discovered numerous errors similar to the following:
(QTAgent32.exe, PID 12348, Thread 61) WebSites.GetWebServer: failed to
create AspNetHelper:
Microsoft.VisualStudio.Enterprise.Common.AspNetHelperException: The
website metabase contains unexpected information or you do not have
permission to access the metabase. You must be a member of the
Administrators group on the local computer to access the IIS metabase.
Therefore, you cannot create or open a local IIS Web site. If you
have Read, Write, and Modify Permissions for the folder where the
files are located, you can create a file system web site that points
to the folder in order to proceed. --->
System.Runtime.InteropServices.COMException: Unknown error
(0x80005000)
That lead me to this blog post which seems to have resolved the issue.
I just needed to go to "Turn Windows features on or off" and add IIS 6 Management Compatibility and all four subcomponents. I'm running Windows 7 Home Premium which doesn't have the Windows Authentication option, but that didn't seem to be an issue. Give it a shot and see if that resolves the issue for you.
You may need to enable "Use IIS" in the project properties, then click "Create Virtual Directory". Do you have IIS Express installed?
from an ASP.Net 3.5 web application, I'm trying to log messages to the Windows EventLog.
I first tried with the EntLib Logginh block, but when this failed I tried with the EventLog class directly. It failed too. They do not throw any exception... the just don't write the message. EntLib did write the message to a file, but not to the Windows EventLog.
Here is my code:
public static void LogMessage(string title, string message){
//EventLog log = new EventLog();
//log.Source = LOG_SOURCE;
//log.WriteEntry(message, EventLogEntryType.Error);
//EventLog.WriteEntry(LOG_SOURCE, message);
LogWriter writer = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
writer.Write(message);
}
I create the log & source in an installer class. Let me know if I should place that code here. The log is created correctly, since I can see it in the EventViewer. The source is created correctly, since I can see it in the "EventLog\MyLog" folder at the regedit.
I've been reading and there is an article stating following line could help:
EventLogPermission perm = new EventLogPermission(EventLogPermissionAccess.Administer, ".");
perm.PermitOnly();
but it didn't.
If it helps, my code structure is as follows:
Class library project (here is the LogMessage method)
Class Library project (here are the methods which catch exceptions and call LogMessage)
ASP Net web application project (web pages. This layer calls layer #2. Here is my installer class too)
Web setup project (this has custom actions pointing to web setup project output)
Could you please help to figure out what's happening???
Thanks
I found the following resource: "http://www.netframeworkdev.com/net-base-class-library/trouble-writing-to-eventlog-16723.shtml", so it seems it is not possibly to create custom logs from ASP... still investigating
Try giving the Network Service account the appropriate permissions