How to configure PDFNet for .NET application to publish to Citrix server? (AnyCPU) - winforms

So I have been trying to config the project to make it work on our server via Citrix.
I used this line of code to set the path:
private static pdftron.PDFNetLoader loader = pdftron.PDFNetLoader.Instance().Path(String.Format(#"{0}\{1}",
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(IndexUIZoom)).Location), #"PDFNet"));
I got this error every time (bin is where the .exe file is):
INFO Program [(null)] - Path: [bin]\PDFNet -
ERROR Program [(null)] - System.IO.FileNotFoundException: Could not load file or assembly 'PDFNet.dll' or one of its dependencies.
The specified module could not be found. File name: 'PDFNet.dll'
Everything works fine on local machine. I got the error above whenever I run from Citrix, or log into the server machine and run from there.

Most likely your server is missing the MS VC++ Runtime dependencies. Developer machines usually have them installed as part of a Visual Studio installation, but servers often do not. You can download MS VC++ installers from MSDN.
To find the exact one you need to download please see section 3.2.1 of the Getting Started Guide for PDFNet .Net below. Note you need to also match the runtime 32 or 64 bitness of your process, for both PDFNet.dll and the MS VC++ runtime.
PDFNet .Net 4.0+ Getting Started Guide
PDFNet .Net 2.0-3.5 Getting Started Guide
https://www.pdftron.com/documentation/windows/guides

Related

The invocation of the constructor on the Cefsharp.Wpf.ChromiumWebBrowser that matches the specified binding constraints threw an exception

Line number '81' and line position '18' ---> System.IO.FileNotFoundException: Could Not load file or assembly 'Cefsharp.Wpf.ChromiumWebBroser.NoInliningConstructor()'.
It works on my machine, but when I release an EXE/MSI file and install to a machine of my client mechanic it throws the exception above.
The CefSharp library requires the Visual C++ Redistributables. Install them to your clients machine or add them as a prerequiste to you installer. Choose the appropriate redistributable for your version:
CefSharp 65.0.0+ requires VC++ >= 2015
CefSharp 51.0.0 to 63.0.0 requires VC++ 2013
CefSharp 45.0.0 to 49.0.0 (.NET Framework 4.0) requires VC++ 2013
CefSharp 43.0.0 and below (.NET Framework 4.0) requires VC++ 2012
If this does not help, check if all the files that are required are copied to your clients machine. Check this list for the required files for CefSharp. Compare the expected files from your build output folder to the installed files, because the exception clearly states that either CefSharp.Core.dll or one of its dependencies is missing.
There is a known issue that installers sometimes do not include unmanaged resources. If any resource or DLL is missing, then you have to manually add them to your setup.

Microsoft.Bcl.AsyncInterfaces error (in CSVHelper method) when running the application installed by Visual Studio Setup project

I have a WPF application that reads a CSV file using CSVHelper which I installed using NuGet. Here's the project, system, etc version info.
Microsoft Windows 7 Professional Version 6.1.7601 Service Pack 1 Build
7601
Microsoft Visual Studio Community 2019 Version 16.4.5
NuGet Package Manager 5.4.0
WPF Project Target Framework: .NET Framework 4.7.2
CSVHelper Version: 15.0.5
CSV reader method is straightforward; read a file and put it in a list. Nothing fancy. I'll link the entire project at the bottom so you can download and try it out if you want.
When I run the executable made in either Release or Debug builds, they work fine. They read the file, put contents in a list, and display on a DataGrid just fine. As a next step, I created a standard Visual Studio Setup project, and created an msi installer, which I used to install the app in my PC.
When I run that executable (which is in my Program Files directory), however, the application throws an exception. Here's the exception message and Stack Trace.
Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
at ReadCSVTest.MainWindow.ReadPeopleList(String path, List`1& people, String& msg)
at ReadCSVTest.MainWindow..ctor()
Since the error says couldn't load the assembly Microsoft.Bcl.AsyncInterfaces, I added that from NuGet and ran everything again, and I still get the error. What's the problem here? What does it mean that Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.? And why do I only get this exception when I run the executable installed by the Setup project?
Please download the entire project from HERE.
Just so anyone runs into the same issue in the future; as Jones suggested in the comments, downgrading each of the two libraries to following versions fixed the issue for me.
CsvHelper ==> 12.3.2
And
Microsoft.Bcl.AsyncInterfaces ==> 1.0.0

Deploy WPF Project to UAT and Prod Environment

I am trying to enable the software tester to install 2 versions of the same application (one UAT and the other Production) on the same computer. I am using Visual Studio 2013 and the exe(installer) is created using ClickOnce. I was able to publish 2 versions to a directory, however, when the tester would try to install the second version it would overwrite the previous version. I did some research and found out that I had to rename the assembly. However, if I rename the assembly , I get the following error
"A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll"
Inner Exception : Could not load file or assembly 'xxx, Culture=neutral' or one of its dependencies. The system cannot find the file specified.":"xxx, Culture=neutral"}
I have tried cleaning, rebuilding , changing the namespace and I have absolutely no idea where I am going wrong. Any assistance will be greatly appreciated!

SSIS C# 2012 Script Task referring WinSCPnet.dll fails when run from SQL Server Agent with "Exception has been thrown by the target of an invocation"

I have an SSIS package (created in VS 2013) that contains a C# 2012 Script Task.
The job of the script task is to download a file from an SFTP server using WinSCP .NET assembly and place it on my server (Windows Server 2012 R2 with SQL Server 2014)
My package runs fine when I run it on my Dev machine, but when I deploy to the server my package fails at this task with the error message
Exception has been thrown by the target of an invocation
I've done some digging and it looks like it has something to do with the reference to WinSCPnet.dll.
Quoting WinSCP article on Exception has been thrown by the target of an invocation:
This is just a high-level exception. The root cause is usually stored in the InnerException.
If you are getting this exception in SSIS, you can use try … catch block to capture the error, as show in the example for using WinSCP .NET Assembly from SSIS.
If you cannot access the inner exception easily, inspect WinSCP session log and debug log file (Session.SessionLogPath, Session.DebugLogPath). If those file are not even created, the root cause can be loading of WinSCPnet.dll assembly. See Could not load file or assembly ‘file:///…\WinSCPnet.dll’ or one of its dependencies. The system cannot find the file specified..
Installing the assembly to allow its loading is covered in Installing section of Using WinSCP .NET Assembly from SQL Server Integration Services (SSIS):
Installing
First, you need to install the WinSCP .NET assembly. Do not use the NuGet package.1
You also need to install the assembly to the GAC or subscribe AppDomain.AssemblyResolve event to allow loading the assembly.
The installation to GAC is covered by Installing to GAC section of Installation instructions for WinSCP .NET assembly:
Installing to GAC
In special cases, you may need to install the assembly into Global Assembly Cache (GAC), particularly to use it from SSIS.
When you install the assembly to GAC, you need to configure a path to WinSCP executable.
On Development Machine
To install the assembly into GAC on development machine, i.e. the one that has Windows SDK installed, use following command:
gacutil.exe /i WinSCPnet.dll
Windows SDK comes with Microsoft Visual Studio. You can also install it separately.
Use correct gacutil.exe for your version of .NET framework:
For .NET framework 4.0 or newer, use gacutil from Windows SDK 7.1 (or newer):
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\bin\gacutil.exe;
For .NET framework 3.5, use gacutil from Windows SDK 6.0:
C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Bin\gacutil.exe
On Production or User's Machine
To install the assembly into GAC on production or user’s machine, you may install the assembly into GAC using:
Windows Installer, by creating .msi package;
Any other installer system that supports installing to GAC, e.g. Inno Setup;
System.EnterpriseServices.Internal.Publish.GacInstall method. PowerShell example:
Add-Type -AssemblyName "System.EnterpriseServices"
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("WinSCPnet.dll")
An absolute path to the DLL needs to be specified and Administrator privileges are required. Otherwise the above method will fail (and the only indication of the failure is sent to Windows Event log).
See How to fix NuGet WinSCP.NET in SSIS Script Task?
You need to install WinSCPnet.dll in the Global Assembly Cache for SSIS to pick up this dependency, see this blog for further details. You can install a DLL in the GAC using the following steps, see the documentation for further details:
Copy the WinSCPnet assembly to your local computer into a folder.
Start Visual Studio Command Prompt.
Type the following command: gacutil.exe /if ""
This installs the assembly to the GAC, overwriting any existing assembly that has the same assembly name.
If you have already registered the appropriate Dll's are are still getting this error, and you are passing in variables that are package-scoped, be sure to add them to the "ReadOnlyVariables" in the script task.
Right click on the task and click "Edit...", then click the "..." on the "ReadOnlyVariables" property, and add the variables that are referenced in your script.

How to install Crystal Reports for .Net 3.5 Winforms application

We have a VB.Net Winforms (x86) application that uses the freely redistributable version of Crystal Reports. Although the application works fine on my test machine, when installing on a client's machine and trying to print a report from the application, the error: The system cannot find the file specified. File name: 'CrystalDecisions.CrystalReports.Engine ... is displayed.
The inno-setup includes the CR redistributable "CRRedist2008_x86.msi" which was installed by the client during the installation. (We also tried running the "CRRedist2008_x64.msi" but received an "unsupported processor type" error).
I have read about Merge Modules that are prerequisites for .NET 1/2 (VS 2002/2005), but cannot find any useful information related to .NET 3.5 and am wondering if these files are still required and how to package and deploy them if they are in fact needed.
Any guidance on how to resolve this installation issue is much appreciated.
Edit
The Inno-Setup contains the following command that checks to see if CR is installed and if not the MSI is launched from the final setup form:
[Run]
Filename: "{app}\CRRedist2008_x86.msi"; Description: "Crystal Reports"; Flags: nowait postinstall skipifsilent; Check: EnsureCrystalReports105Installed();
The problem is that you are not actually executing the MSI file. You can see this by running your installer with /LOG and reviewing the resulting log file.
This is because MSI files cannot be directly executed -- they're data files, not programs.
To resolve this, you need to run msiexec instead, passing the MSI file as a parameter; eg.
[Run]
Filename: {sys}\msiexec.exe; Parameters: "/i ""{app}\CRRedist2008_x86.msi"""; ...
You should review the command line parameters accepted by msiexec and properties accepted by the MSI file to see if you want to do something different, eg. running the install silently instead of interactively.
Also, running it as postinstall is fine if this component is optional for your application and it can gracefully handle it not being installed. If this is not the case then you should treat it as a prerequisite instead and always install it via PrepareToInstall.

Resources