Crystal Report to PDF in .NET - c#

I put together a POC console app. to generate a PDF from a Crystal Report (using CrystalDecisions libraries)
It all works fine on my dev. box, but encounters an exception when executed elsewhere:
Could not load file or assembly
'CrystalDecisions.ReportAppServer.CommLay er, Version=13.0.2000.0,
Culture=neutral, PublicKeyToken=692fbea5521e1304' or on e of its
dependencies. The system cannot find the file specified.
Unhandled Exception: System.TypeInitializationException: The type
initializer for
'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an
exception. --
-> System.IO.FileNotFoundException: Could not load file or assembly 'CrystalDeci
sions.ReportAppServer.CommLayer, Version=13.0.2000.0, Culture=neutral, PublicKey
Token=692fbea5521e1304' or one of its dependencies. The system cannot find the f
ile specified.
at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
I believe this is caused by the absence of the Crystal Reports runtime (which is not explicitly installed).
1) Can anyone please confirm this?
2) Is there any way to get this working without installing Crystal Reports runtime on the target machine(s)?
I've read about building an installer with merge modules etc. but this is a console app and I don't want to go down that route.
Thanks in advance.
EDIT:
I checked out the DLL dependencies and this actually appears to be missing libraries API-MS-WIN-CORE-*

You will need to distribute the runtime for Crystal Reports to work.
Another option is to write second app to generate the pdf files which you could install on a server, then each of your console apps send a request to the new server app which sends back the pdf. This would mean the crystal runtime would only be installed on one machine, and the original console app wouldn't need to worry about it.
Just for information, the crystal runtime can be downloaded from here: http://scn.sap.com/docs/DOC-7824

Related

Could not load file or assembly 'PdfSharpCore, Version=1.3.40.0

I am using PdfSharpCore version 1.3.40 in a MVC ASP.Net netcoreapp2.1 and it works perfectly on my windows localhost, but when I publish it on a server Linux running Apache the follow exception occurs:
Could not load file or assembly 'PdfSharpCore, Version=1.3.40.0, Culture=neutral, PublicKeyTo ken=null'. The system cannot find the file specified.
I already checked that the PdfSharpCore dll is there, but the system couldn't find it.
Does anyone know what's going on?
We managed to solve the problem, we were forgetting to replace the .deps.json file that contains the dependencies with the new PdfSharpCore.dll dll included in the project. Solved!

Viewer lines in License.licx breaking build process

I've recently been tasked with adding a report to an older WPF application. Part of the process involved adding ActiveReports to the solution in question.
After getting the report implemented and tested on my local machine, it came time to commit it up to our Dev/Test build environments. Everything went fine, until I attempted to run the application on a machine that did not have ActiveReports installed and licensed on it - I got the "Viewer needs to be licensed error window."
Here's where things get confusing, though. It should be working.
For starters, I'm running ActiveReports 8.0.133.0.
The contents of my licenses.licx file are:
GrapeCity.ActiveReports.SectionReport, GrapeCity.ActiveReports.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff
I've generated a satellite licensing DLL for the WPF project's executable, and ensured that it's referenced and set to Copy Local = true. (I've already dealt with this in the past.)
Even though it's not a web project, for safety's sake, I used the WebKey Generator and added an Active Report 8 Developer key to the app.config file.
It gets more interesting, though. When I add the following lines to my licenses.licx file, as the error window I get above suggests I should do:
GrapeCity.ActiveReports.Viewer.Win.Viewer, GrapeCity.ActiveReports.Viewer.Win.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff
GrapeCity.ActiveReports.Viewer.Wpf.Viewer, GrapeCity.ActiveReports.Viewer.Wpf.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff
When I try to simply build the project in Dev, the build fails with the following message:
[10:29:34] [exec] (CompileLicxFiles target) ->
[10:29:34] [exec] Properties\licenses.licx(2): error LC0004: Exception occurred creating type 'GrapeCity.ActiveReports.Viewer.Win.Viewer, GrapeCity.ActiveReports.Viewer.Win.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff' System.ComponentModel.LicenseException: License cannot be confirmed. Error code: 01-001 [C:\CheckoutDirectory\Project\[(0) BUILD]\UI\UI.csproj]
[10:29:34] [exec] Properties\licenses.licx(3): error LC0004: Exception occurred creating type 'GrapeCity.ActiveReports.Viewer.Wpf.Viewer, GrapeCity.ActiveReports.Viewer.Wpf.v8, Version=8.0.133.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff' System.ComponentModel.LicenseException: License cannot be confirmed. Error code: 01-001 [C:\CheckoutDirectory\Project\[(0) BUILD]\UI\UI.csproj]
For those who don't want to scroll:
System.ComponentModel.LicenseException: License cannot be confirmed. Error code: 01-001
The end result is a sort of Morton's Fork of badness. Either I can build the app, but I can't run the report (which, is sort of the point of me making these changes), or I simply can't build the app at all.
Question: What can I do to get the report viewer to run without a license exception and keep the application building? I should also note, I'm on a short deadline with this!
I was correct to add the Win and WPF viewer lines; it turns out the answer was to upgrade the Build server with Active Reports 8. From there, everything went swimmingly.
TL;DR - Upgrade everything that needs to be upgraded!

BadImageFormat Exception at Microsoft.CSharp library

I'm having little problem running my C# application after switching to Windows 8.1 from 8.
The problem is that I get this exception from title and there's not much help online. I tried to pinpoint the problem and it seems like my x64 application is trying to call x86 CSharp library. The reference in project leads to a DLL file, that upon calling x64 dumpbin program with /headers parameter outputs:
Dump of file Microsoft.CSharp.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (x86)
3 number of sections
4FFA5C64 time date stamp Mon Jul 09 06:21:56 2012
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2022 characteristics
Executable
Application can handle large (>2GB) addresses
DLL
Notice the machine is x86, while the application is running in x64 (checked with Environment.Is64BitProcess). This might be the problem I'm facing, however I can't find way to solve it - there seems to be no x64 .Net libraries installed. The only ones I have found are at: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework. Or maybe I'm completely off and there's some other problem. Anyway the exception occurs at startup in one of constructors and full detail is:
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
"Could not load file or assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest."
Edit:
While still panicking, I solved this by downloading CSharp.dll and replacing the dummy 0-byte file in path shown in answer by it.
The module was expected to contain an assembly manifest
You've been looking at a reference assembly, it is not the one that's actually loaded when you run your program. Microsoft.CSharp.dll is stored in the GAC, put there by the .NET installer. You can see the file by navigating to c:\windows\microsoft.net\assembly\gac_msil\microsoft.csharp. Keep clicking until you get to the file.
The exception message is a very unhealthy one, it doesn't recognize the DLL as a .NET assembly. There are few decent explanations for that, other than the file being corrupted. File corruption is always bad news, a strong hint that your hard-disk is failing. You'll need to get it fixed, follow-up if necessary at superuser.com

Unable to run Websphere MQ application once deployed

Good day. I have developed an application which works successfully on my local machine but I have run into a problem when moving out to production.
The error is as follows:
System.IO.FileNotFoundException: Could not load file or assembly 'IBM.XMS.Admin, Version=2.5.0.0, Culture=neutral, PublicKeyToken=d2666ab12fca862b' or one of its dependencies. The system cannot find the file specified.
File name: 'IBM.XMS.Admin, Version=2.5.0.0, Culture=neutral, PublicKeyToken=d2666ab12fca862b'
I understand where this file is - C:\Prog... - and my .Net application is simply referencing IBM.XMS.dll which works. It's when I deploy and run I get the error above.
I used the following installation instructions and restarted the system too:
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzav.doc/un10290_.htm
Your application is built with XMS v2.5. Do you have XMS v2.5 (shipped with MQ v7.5 client) installed on the other machine?
check out Microsoft's fusion log viewer and see how you get on.
In my experience when I see this message the keywords are or one of its dependencies. The fusion log may help you find out which one.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Expression.Encoder.Utilities.dll'

i just wrote a program that uses microsoft encoders and merge videos and audios , its working fine in my PC (Windows7 ) and when i test it on other PCs (Windows7,Windows XP [.net 4.0 installed]] it is giving me following exception
its even giving me exception when i try to run the sample sdk applications to other pcs ..(with no microsoft expression installed)
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'Microsoft.Expression.Encoder.Utilities.dll' or one of its dependencies. T
he specified module could not be found.
at Simple.Program.Main(String[] args)
how can i solve this error ,
or what are the ways to deploy standalone application , without pc pre installed microsoft expression studio.
thanks
Microsoft.Expression.Encoder.Utilities.dll is part of Expression Studio. If it isn't installed on the target machine it will not be found.
I don't know if these DLLs can be freely distributed, but you should find out before trying to distribute them with your application.
try to locate this dll-file on your machine, and distribute it with your executable to a pc that hasn't got expression installed.
when a program is about to use a dll, it looks in some predesignated places on the computer. one of the first places is in the folder the executable is executed in. one of the later places is probably c:\windows\system32
you have the filename though, so it shouldn't be that hard. unless microsoft has created some sort of mechanism stopping the distribution of the expression utilities.

Categories