Crystal report fails to load when application is deployed in IIS - crystal-reports

I copied the packageTmp over to the inetpub/wwwroot, then added a website and included it as my path.
Installed the crystal report runtime, CRRuntime_32bit_13_0_4 - but still did not work.
I also have crystalreportviewers13 folder in wwwroot/aspnet _client/systemweb/4_0_30319
This is the error I encountered when I go to the page with crystal report. May i know where the path is defined? This problem occurs when I deploy my application in IIS.
Exception Details: System.Runtime.InteropServices.COMException: Invalid file name.
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:
[COMException (0x800001fb): Invalid file name.]
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +95
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +270
[CrystalReportsException: Load report failed.]
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +333
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +877
CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob) +1183
CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport() +113
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) +53
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable)
....
This is the .cs code behind the .aspx code,for reportxx.rpt
m_reportxx = new reportxx();
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
DataTable dt = data.GetReport();
reportxx.SetDataSource(dt);
CrystalReportViewer1.ReportSource = m_reportxx;
I tried this and it worked while debugging in the visual studio environment.

I know this is an old post. but For anyone still looking for the answer:
You need to register crystal reports in page markup
<% # Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
Set the property 'Copy to Output Directory' of the report to 'Copy always'
the path of the file in the crystalreportsource will be ~/bin/YOURFOLDER/YOURFILE
<CR: CrystalReportSource ID ="CrystalReportSource1" runat ="server">
<Report FileName="~/bin/oilmovement/rptOMDayEnd.rpt">
</Report>
</CR: CrystalReportSource>
Now the report should work

In my case, I found by 2 days the error and not see nothing wrong...Finally I used Procmon.exe (https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx?f=255&MSPPError=-2147217396) to trace the error.
I Filter by Result + is not + SUCCESS, I tried to run again the web application and appear the Error: ACCESS DENIED to Folder X.
I give the right permission to X folder and works fine.

Related

How to show PDF from .net maui app on Windows

I am just trying to show a PDF file from my .NET MAUI application on Windows and it is giving me the error below.
"System.ComponentModel.Win32Exception: 'An error occurred trying to start process 'C:\Users<username>\Documents\helpfile.pdf' with working directory 'C:\WINDOWS\system32'. The specified executable is not a valid application for this OS platform.'"
My code is below. It has worked in a WPF app but won't work here.
Process.Start("C:\\Users\\<username>\\Documents\\helpfile.pdf"); // removed the username here and above in error message
also tried: (getting helpfile.pdf from install directory)
string _asmPath = Assembly.GetExecutingAssembly().Location;
int lastIndex = _asmPath.LastIndexOf('\\');
string helpfilePath = $"{_asmPath.Substring(0, lastIndex)}\\helpfile.pdf";
ProcessStartInfo startInfo = new ProcessStartInfo(helpfilePath);
Process.Start(startInfo);
and I get a similar error:
"System.ComponentModel.Win32Exception: 'An error occurred trying to start process 'C:\Projects\SnapSignalTel\bin\Debug\net6.0-windows10.0.19041.0\win10-x64\AppX\helpfile.pdf' with working directory 'C:\WINDOWS\system32'. The specified executable is not a valid application for this OS platform.'"
How can I open this PDF document (helpfile.pdf) in a MAUI app on Win10?
Thanks for any help!
use Launcher
await Launcher.Default.OpenAsync(new OpenFileRequest("Some Title", new ReadOnlyFile(filepath)));

VSTS BuildClient.GetArtifactContentZipAsync throws Microsoft.VisualStudio.Services.WebApi exception

I'm trying to automate build artifact download. The objective is to download a specific build artifact. When I call BuildClient.GetArtifactContentZipAsync, it throws the following error
I am using the following code
private static void DownloadBuildResults(Build StartedBuild, string ArtifactName)
{
//BuildArtifact drop = BuildClient.GetArtifactAsync(StartedBuild.Id, ArtifactName).Result; //get detiled info
//Console.WriteLine("Build location: " + drop.Resource.DownloadUrl);
//string dropFileName = String.Format("{0}_{1}.zip", StartedBuild.Definition.Name, StartedBuild.BuildNumber);
Stream zipStream = BuildClient.GetArtifactContentZipAsync(79414, "abc").Result; //get content
using (FileStream zipFile = new FileStream("abc.zip", FileMode.Create))
zipStream.CopyTo(zipFile);
Please note that I buildID and artifact name is correct. I have double-checked these values. The above code example is taken from https://github.com/ashamrai/TFRestApi/blob/master/19.TFRestApiAppQueueBuild/TFRestApiApp/Program.cs
Is this a bug in the API/SDK? or Am I doing something wrong?
Here is the sample code if someone wants to give a try
GIST: https://gist.github.com/abhishekgoenka/9759256f995e7f7c9cbcb7872c8591c0
I get following error in code
Stack trace
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.TeamFoundation.Build.WebApi.BuildHttpClientBase.<GetArtifactContentZipAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Utils.Dashboard.FrmAzureDashboard.<BtnDownloadKHP_Click>d__13.MoveNext() in C:\code\MetaFXTools\ui\Utils\Dashboard\FrmAzureDashboard.cs:line 118
I have hit the same issue as well.
What I have determined so far is that the call to GetArtifactContentZipAsync results in a 302 response from the server.
(The Location header in the response is along the lines of: https://artproduks1.artifacts.visualstudio.com/.../_apis/artifact/.../content?format=zip)
Inside of GetArtifactContentZipAsync is a call to httpResponseMessage.EnsureSuccessStatusCode() and this causes the error to be thrown as the library is not expecting a redirect to be returned.
It is possible to create the connection using: new VssConnection(uri, creds, new VssClientHttpRequestSettings{AllowAutoRedirect = true}), so that the redirect is followed, however this then errors with a different message indicating that an incorrect version has been sent to the server.
I got to know the reason of the exception being thrown when calling this API.
In the pipeline if you are using the "Publish build artifacts" to publish the artifacts, the API will work fine. Whereas if you use "Publish pipeline artifact" task, the API will return 302 ("Found").
Microsoft currently has no workaround for this issue and I would suggest you to use either HttpClient or WebClient to download the artifacts.
Is this a bug in the API/SDK? or Am I doing something wrong?
I can confirm the code from ashamrai is correct.(I tested it with my VS2019 16.6 and it works well.) And there's could be something with the values of your variables. I suggest you use try-catch to call the DownloadBuildResults function so that you can share detailed error message here. I just changed a bit from your code above:
class Program
{
static readonly string TFUrl = "https://dev.azure.com/YourOrganizationName/";
static readonly string UserPAT = "YourPAT";
static void Main(string[] args)
{
try
{
int buildId = 832; // update to an existing build definition id
string artifactName = "drop"; //default artifact name
ConnectWithPAT(TFUrl, UserPAT);
Stream zipStream = BuildClient.GetArtifactContentZipAsync(buildId, artifactName).Result; //get content
using (FileStream zipFile = new FileStream(#"C:\MySite\test.zip", FileMode.Create))
zipStream.CopyTo(zipFile);
Console.WriteLine("Done");
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
if (ex.InnerException != null) Console.WriteLine("Detailed Info: " + ex.InnerException.Message);
Console.WriteLine("Stack:\n" + ex.StackTrace);
}
}
}
So you need to make sure:
1.You have a valid PAT which hasn't expired yet, and this PAT has the access to build artifact. Then directly enter the pat in static readonly string UserPAT = "xxxxxxxxxxxxx";. It should be "PAT" instead of "<PAT>".
2.The URL(TFUrl) only needs OrganizationName as part of it.
3.Make sure you choose the correct artifact name.
4.Distinguish the difference between BuildID and BuildDefinitionID.
You can see buildDefinitionID when editing the pipeline:
You can see BuildID when checking the pipeline run results in web portal:
You should use the BuildID as input.
5.Also, the build you run(BuildID) should have the artifact published:
Your pipeline should have Publish build artifacts task. Check the log and make sure something is published, the folder to be published can't be empty.
6.Since you're only testing the code by Download artifact function, make sure you queue/run the build successfully before your run the code. (Wait for the end of the pipeline run.)

Wix bootstrapping. Check if Sap Crystal reports is already installed

I have tried with following registry searches
<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\"
Value="CRRuntime32Version"
Variable="CR32Version"
Format="raw"
Result="value"/>
<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\"
Value="CRRuntime64Version"
Variable="CR64Version"
Format="raw"
Result="value"/>
And I have used Install condition for the msi packages as shown below
<MsiPackage SourceFile="$(var.MyDir)\CRRuntime_64bit_13_0_9.msi"
InstallCondition="VersionNT64 AND (NOT (CR64Version >= 13.0.9))"
Permanent="yes"/>
<MsiPackage SourceFile="$(var.MyDir)\CRRuntime_32bit_13_0_9.msi"
InstallCondition="NOT VersionNT64 AND (NOT (CR32Version >= 13.0.9))"
Permanent="yes"/>
When I tried to install the exe generated with above settings I am getting the following error.
[1B0C:0A7C][2014-08-08T17:54:35]i000: Registry value not found. Key = 'SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\', Value = 'CRRuntime64Version'
[1B0C:0A7C][2014-08-08T17:54:35]i000: Registry value not found. Key = 'SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\', Value = 'CRRuntime32Version'
[1B0C:0A7C][2014-08-08T17:54:37]e000: Error 0x8007000d: Failed to parse condition "VersionNT64 AND (NOT (CR64Version >= 13.0.9))". Unexpected character at position 39.
When I checked manually opening the regedit and checked, I could find the CRRuntime64Version to 13.0.9.
I am really lost in solving this issue. It took me almost one day already trying to resolve this issue.
I also googled this issue and I did not get the relevant information.
Please help me the solution.
Use Win64="yes" in your registry search to tell it to search the 64-bit registry. Replace > with > in your condition to fix your other error.

Why does custom Build Process Template executing PowerShell fail

I've modified a custom build process template to execute Powershell on the build server. This is so I can run some scripts that will automate the deployment of our SharePoint solution. Everything was working fine up until I upgraded the build servers Powershell version from 2.0 to 3.0 (which needed to be done as I was installing SCVMM Admin Console 2012 and Powershell 3.0 was a pre-requisite).
In the build template itself, I'm using a Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess work flow item to execute the PowerShell command with the following properties:
Arguments : String.Format(" ""& '{0}' -DropLocation '{1}' {2} "" ",
ScriptFilename, BuildDetail.DropLocation, PostDropScript2Arguments)
FileName : "powershell"
OutputEncoding :
System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.InstalledUICulture.TextInfo.OEMCodePage)
Now every time I try to execute the build, I get the following error:
Exception Message: File not found: PowerShell (type
FileNotFoundException) Exception Stack Trace: Server stack trace:
at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.Start()
at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.InvokeProcessInternal.RunCommand(AsyncState
state) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message
reqMsg, Boolean bProxyCase) at
System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed,
MessageData& msgData) at System.Func2.EndInvoke(IAsyncResult
result) at
System.Activities.AsyncCodeActivity1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext
context, IAsyncResult result) at
System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor
executor, BookmarkManager bookmarkManager)
Inner Exception Details:
Exception Message: The system cannot find the file specified (type
Win32Exception) Exception Stack Trace: at
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
startInfo) at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.Start()
It seems like the build is no longer able to link the "powershell" command with the actual PowerShell file.
I've manually gone onto the build server and typed "powershell" into a command line and it started PowerShell, as expected.
Has anyone else experienced this issue before?
Thanks very much
Add the full filepath to powershell.exe in the invokeprocess step in your workflow and it should always work (I would not trust the environment-settings for this)
And know, logging in on the server under your own account is not equal to the build server running under a specific account.
In my case same error occurred after deploying Windows Managment Framework 3.0.
It was solved by restarting build controller and agent.

How to create NTEventlogAppender.dll as required for logging event in the eventlog using log4cplus

First, Let me thank for the log4cplus source code.
I am facing one issue as follows:
What I am trying to do?
I want to log the messages to event log on windows.
What did I do?
I could get the event logging enabled by in including following .h
#include <log4cplus/nteventlogappender.h>
And creating the appender as follows:
SharedAppenderPtr append_3(new NTEventLogAppender(LOG4CPLUS_TEXT("127.0.0.1"), LOG4CPLUS_TEXT("log"), LOG4CPLUS_TEXT("source")));
append_3->setName(LOG4CPLUS_TEXT("ToEventlog"));
Logger to_eventlog = Logger::getInstance(LOG4CPLUS_TEXT("to_eventlog"));
to_eventlog.addAppender(append_3);
to_eventlog.setLogLevel(log4cplus::ALL_LOG_LEVEL);
And logging as
Logger to_eventlog = Logger::getInstance(LOG4CPLUS_TEXT("to_eventlog"));
LOG4CPLUS_FATAL(to_eventlog, “Test Message.”);
When I log the message, I get following in the event log:
The description for Event ID 4096 from source source cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Test Message.
the message resource is present but the message is not found in the string/message table
I tried to create a dll with name NTEventLogAppender.dll with string table resource and a string with id 4096 (as hardcoded in the nteventlogappender.cxx file in log4cplus) and compiled it with resource only dll (/NOENTRY) but I still keep getting above error.
I already tried question to log4cplus-devel#lists.sourceforge.net but did not get any answer yet.
Any help on how to create this dll would be greatly appreciated.
Thanks.
This is how I resolved this issue:
comipiled NTEventLogAppender.mc file using commands:
mc -U NTEventLogAppender.mc
rc -r NTEventLogAppender.rc
link -dll -noentry -out:NTEventLogAppender.dll NTEventLogAppender.res
where NTEventLogAppender.mc has following contents
MessageIdTypedef=DWORD
SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
Warning=0x2:STATUS_SEVERITY_WARNING
Error=0x3:STATUS_SEVERITY_ERROR
)
FacilityNames=(System=0x0:FACILITY_SYSTEM
Runtime=0x2:FACILITY_RUNTIME
Stubs=0x3:FACILITY_STUBS
Io=0x4:FACILITY_IO_ERROR_CODE
)
LanguageNames=(English=0x409:MSG00409)
; // The following are message definitions.
MessageId=0x1000
SymbolicName=SVC_TEST
Language=English
A message for something.
.
; // A message file must end with a period on its own line
; // followed by a blank line.
copied the NTEventLogAppender.dll to c:\windows\system32
and ran the above mentioned test program and found that event log found the message resource correctly.
you need to register this dll by copying following in .reg file and running the same
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\log\source]
"EventMessageFile"="C:\\windows\\system32\\NTEventLogAppender.dll"
"CategoryMessageFile"="C:\\windows\\system32\\NTEventLogAppender.dll"
"TypesSupported"=dword:00000007
"CategoryCount"=dword:00000005