Can't find initialization file gs_init.ps - c#

I have a .net windows form application that uses ghostscript. Only on 1 machine do i get an error message. On all others (100s) it works find. This is in a Citrix environment.
The error is "AFPL Ghostscript 8.53: Can't find initialization file gs_init.ps"
I have checked and the file does exist.

I've had a similar problem when compiling a latex file on OSx (pdflatex *.tex).
The problem arose because of gs installed by MacTeX.
The command pdflatex was using the command gs installed by MacTex and not the one installed by brew.
I fixed the problem by running the following command brew link --overwrite ghostscript

I've had a similar problem when calling the GS dll from a Delphi application; I solved it by setting the environment variable.
From the documentation: Ghostscript tries directories in this order:
The current directory (unless disabled by the -P- switch);
The directories specified by -I switches in the command line, if any;
The directories specified by the GS_LIB environment variable, if any.

Related

Dotnet: Works in VSCode's OWN TERMINAL, but OMNISHARP: 'dotnet.exe' is not recognized

How is this possible?
I installed .net sdk 6.0.405: dotnet-sdk-6.0.405-win-x64.exe
I can in windows terminal and power shell run: dotnet --version: 6.0.405 ✅
I CAN ALSO IN VSCODE IN ITS BUILTIN TERMINAL, run: dotnet --version: 6.0.405 ✅✅
But in the OUTPUT tab, choosing OmniSharp Log from the dropdown, it says:
[ERROR] A .NET 6 SDK for x86_64 was not found. Please install the latest x86_64 SDK from ...
I switched vscode explorer settings to use external terminal.
And this terminal setting to command prompt:
Terminal › Integrated › Default Profile: Windows
The default profile used on Windows. This setting will currently be ignored if either terminal.integrated.shell.windows or terminal.integrated.shellArgs.windows are set.
I have dotnet in the PATH (and it works in terminals and in vscode's terminal)
I restarted vscode, AND REINSTALLED the dotnettools "C# for Visual Studio Code (powered by OmniSharp)" extension. I went to the online store and from the right column under Resources I downloaded the ms-dotnettools.csharp-1.25.2#win32-x64.vsix to make sure I get the right one. And restarted vscode.
I tried this setting:
Omnisharp: Dotnet Path
Specified the path to a dotnet installation to use when "useModernNet" is set to true, instead of the default system one. This only influences the dotnet installation to use for hosting Omnisharp itself. Example: "/home/username/mycustomdotnetdirectory".
C:/Program Files/dotnet/sdk/6.0.405
And this setting:
Omnisharp: Sdk Path
Specifies the path to a .NET SDK installation to use for project loading instead of the highest version installed. Applies when "useModernNet" is set to true. Example: /home/username/dotnet/sdks/6.0.300.
C:/Program Files/dotnet/sdk/6.0.405
And restarted vscode. And now it says:
[ERROR] Error: Command failed: dotnet.exe --version
'dotnet.exe' is not recognized as an internal or external command,
operable program or batch file.
What? W H A T? lol
What could be wrong? Why isn't it saying where it expected to find it and what to do to locate it? Is there a setting to specify the dotnet.exe path to this C# extension? Does it need always-on internet or something? Does it have DRM? Does it need Edge installed? Wtf?🙂
🙃😭 I just need intellisense; and I've wasted 2h, on only microsoft-owned products.
#Microsoft 0/5 stars
Still don't know why it happens, but here's how to solve it:
The problem was from this: I like to keep all my visual studio code extensions as .vsix files locally in folders so I can remember and get them easily & offline. Sensible enough choice, and I had the correct ms-dotnettools.csharp-1.25.2#win32-x64.vsix for my platform.
But in VSCode, when I install this particular extension via VSIX, even though it succeeds, it can't find .net. If you instead install the extension "normally", ie via vscode's own download, it seems vscode does some extra configuration steps while installing, and probably sets the .net paths correctly or something. Because now it works.
So TL;DR: don't install ms-dotnettools.csharp via vsix, it seems bugged. 😶
Would love to see an answer explaining what's wrong / how to actually do via vsix; but I don't have any more time to debug this rn.

The file ChromeDriver does not exist when running on Docker

I'm trying to run Selenium on Docker using Azure Function in C#. I've installed Selenium.WebDriver and Selenium.WebDriver.ChromeDriver nuget packages. In docker file I've also put code for installing Chrome driver, but when I try to create ChromeDriver in code, I get exception that chromedriver can't be found.
When I list all files in directory, I can see that there is chromedriver.exe file listed:
but when I try to create a new Chrome driver using this line:
IWebDriver driver = new ChromeDriver(Environment.CurrentDirectory);
I get the following exception:
The file /home/site/wwwroot/bin/Debug/netcoreapp3.1/chromedriver does
not exist. The driver can be downloaded at
http://chromedriver.storage.googleapis.com/index.html.
Why chromedriver.exe file is not recognized? When I run the same code without Docker, everything works fine.
Add the absolute path of chromedriver.exe to container PATH environment variable
Typically Windows executables end with .exe while Linux executables have no file extension. A file being executable on Linux is a consequence of file permissions rather than some naming convention.
The file path in the exception message uses forward-slashes / as file path delimiters rather than back slashes \ leading me to believe you have downloaded a Windows-compatible ChromeDriver which you are attempting to run on a Linux machine.
Solution: download the Linux driver instead when deployed via Docker.

.NET executables do not work after overwritten with new versions

I faced very strange behaviour - after I overwrite .NET exectables with new versions from network drive it cannot start.
When try to start from Windows Explorer it shows me following error:
[Window Title]
C:\Programs\zzz\clients.net\zzzNet.exe
[Content]
C:\Programs\zzz\clients.net\zzzNet.exe
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I tried to execute following commands:
SxsTrace Trace -logfile:SxsTrace.etl
SxStrace Parse -logfile:SxSTrace.etl -outfile:SxSTrace.txt
And got following result:
=================
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = AMD64
CultureFallBacks = en-US;en;ru-RU;ru
ManifestPath = C:\Programs\zzz\clients.net\zzzNet.exe
AssemblyDirectory = C:\Programs\zzz\clients.net\
Application Config File = C:\Programs\zzz\clients.net\zzzNet.exe.Config
-----------------
INFO: Parsing Application Config File C:\Programs\zzz\clients.net\zzzNet.exe.Config.
INFO: Parsing Manifest File C:\Programs\zzz\clients.net\zzzNet.exe.
INFO: Manifest Definition Identity is (null).
ERROR: Line 0: XML Syntax error.
ERROR: Activation Context generation failed.
End Activation Context Generation.
It is quite simple .NET application (1 exe + 8 dll files). It was built for .NET 3.5 Client Profile.
I not defined any special "manifest" there. Just clicked "New Windows Forms Project" in Visual Studio and developed it.
Also app.config does not contain anything special - only primitive standard settings - appSettings and userSettings sections.
On PC where I developed it all is perfectly works. Problems only began when I copy these binaries to this particular VM and try to start.
Also please note - these executables were not installed in GAC or such, I just copied them into a folder on VM and started. And when it was 1st time all was working fine.
So, the problem pattern is following:
Copy .NET execuatbles to new VM (it is Win 7 x64), run it, all is working fine. Close it.
Build new version of .NET execuatbles on host PC, copy new .NET execuatbles to VM (with files overwriting).
Try to start - got mentioned problem.
After some shaman-style actions (like OS reboot, etc) it begin to work but why that happened at all?!
Why replacing .NET executables with new versions is causing SUCH HUGE PROBLEMS?!
Also the BIG QUESTION - is there any special procedure to replace .NET executables to keep them working? Because it is a new app development, I do not want lost so much time on every new executables installation. :-\
Could you please help? Because it looks completely weird!
Thank you in adance.
PS. I checked all VS projects - all they have PlatformTarget=AnyCPU. Also in run-time I can see ProcessType=MSIL (I show this info in AboutBox for application). So, there is no mix of x86/x64 binaries.
It seems that was related to mapped network drive behavior.
When I copied new files from network drive folder it copied wrong files - a strange random mess of new files and older ones (which were there before I updated them on VM host).
The scenario to make it working:
on VM: delete all files in a folder on network drive
on VM host: copy new files into a folder which is mapped as network drive on VM
on VM: copy files into target folder
on VM: run application - it works now
Weird thing. I remember I have seen something similar with Windows Explorer on Windows 2008 behaviour when copying updated win32 binaries.

DebugAdapter bin folder not found on path "....vscode/extensions/ms-vscode.csharp-0.3.7/coreclr-debug/debugAdapters/OpenDebugAD7.exe."

OS: Windows 10
dotnet-cli:
Version: 1.0.0-beta-001598
Commit Sha: 7582649f88
This is after following the instructions here for C# debugging. Does it work yet for windows?
According to the error message, it looks like you did not install the C# extension as per the instructions https://microsoft.gallery.vsassets.io/items?itemName=ms-vscode.csharp
Open your command pallet and verify that the correct version is installed. Or, if it is, remove it and try installing again

Cannot install windows service

I have created a very simple window service using visual studio 2010 and .NُET 4.0.
This service has no functionality added from the default windows service project, other than an installer has been added.
If I run "installutil.exe appName.exe" on my dev box or other windows 2008 R2 machines in our domain the windows service installs without issue.
When I try to do this same thing on our customer site, it fails to install with the following error.
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\TestService\WindowsService1.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515).
This solution has only 1 project and no dependencies added.
I have tried it on multiple machines in our environment and two in our customers. The machines are all windows 2008 R2, both fresh installs. One machine has just .net 2.0 and .net 4.0. The other .net 2, 3, 3.5 and 4.
I am a local admin on each of the machines.
I have also tried the 64bit installer but get the following error, so I think the 32 bit one is the one to use.
System.BadImageFormatException
Any guidance would be appreciated. Thanks.
Another reason for this error might be that you copied your program from a source which windows considers untrusted.
You can unblock the assembly by clicking "unblock" after you right-click and select properties on the file.
Need to unblock files. or at least that's what fixed mine.
To do 'bulk' unblock in Powershell
get-childitem *.* | Unblock-File
or in DOS:
FOR %a in (*.*) do (echo.>%a:Zone.Identifier)
When we copy executable from another computer, Windows mark a flag on them for protection. Right Click on executable and in properties Click Unblock. It would clear flag and service executable would Install.
This issue came about for me because I was trying to install the service from a network location. By copying the service.exe to the local machine prior to using installutil, it fixed my problem and the service installed successfully.
don't forget to vote up...
Try the SC as follows:
1. open command line
2. write the below-
sc create ServiceName BinPath= "ExePath".
report on results...
I also faced the same issue. In my case I was deploying new version of utilities , i copied new exe , installog files and then trying to uninstall the utils.
I copied back the old version , uninstal the utils , copied the new version and installed it again. Anyway it is the logical sequence I should have followed in first place.
i have this issue and it for different between of .net version of util and my service
i use util for .net 2 and my service build with .net4
In my case this error was caused by accidentally passing the directory containing the service to InstallUtil instead of passing the service exe.
Obviously human error but I found the error message quite misleading.
you can use this command in developer command prompt run administrator
installutil C:\...\MyService\bin\Debug\MyService.exe
As per #doublehelix's response above, this answer put me on track for my particular issue which related to a service issue running in Windows XP (Unblock is not an option in the security tab that I could find). In my case I was attempting to run a service from a separate drive (i.e. not on the same drive as Windows and not under program files) although the actual physical disk was the same. Moving my service into the Program Files folder solved my underlying issue. (I intended to 'comment' against #doublehelix's answer but I don't seem to be able to in my current status).
Simply right click on your service files and select properties and then check the unblock checkbox
https://brianseekford.azurewebsites.net/2011/07/13/hresult-0x80131515-when-running-installutil-to-install-a-net-service/
Unblocking files did the job here. Weird thing is that the blocked files came from a signed installer run with admin privileges. Had to unblock several files in several folders at once.
I used the following registry tweaks to add context menus to a folder or file when Shift + right-click is pressed (it doesn't show up if just right-clicked).
Credits and references to the author in each code block.
Folder tweak:
Just save it as ShiftUnblockFolder.reg and import into Registry.
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: March 17th 2019
; Tutorial: https://www.tenforums.com/tutorials/129101-add-unblock-file-context-menu-windows-10-a.html
[HKCR\Directory\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
"SubCommands"=""
[HKCR\Directory\shell\unblock\shell\001flyout]
"MUIVerb"="Unblock files only in this folder"
[HKCR\Directory\shell\unblock\shell\001flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' | Unblock-File"
[HKCR\Directory\shell\unblock\shell\002flyout]
"MUIVerb"="Unblock files in this folder and subfolders"
[HKCR\Directory\shell\unblock\shell\002flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' -recurse | Unblock-File"
Single file tweak:
ShiftUnblockFile.reg
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: March 17th 2019
; Tutorial: https://www.tenforums.com/tutorials/129101-add-unblock-file-context-menu-windows-10-a.html
[HKCR\*\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
[HKCR\*\shell\unblock\command]
#="powershell.exe Unblock-File -LiteralPath '%L'"
[HKCR\Directory\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
"SubCommands"=""
[HKCR\Directory\shell\unblock\shell\001flyout]
"MUIVerb"="Unblock files only in this folder"
[HKCR\Directory\shell\unblock\shell\001flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' | Unblock-File"
[HKCR\Directory\shell\unblock\shell\002flyout]
"MUIVerb"="Unblock files in this folder and subfolders"
[HKCR\Directory\shell\unblock\shell\002flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' -recurse | Unblock-File"
You can try to make a Setup Project for your service and run the MSI file on that server.

Categories