Won't run .exe correctly on Windows Server - c#

I'm trying to run a Console Application on Windows Server 2019 (x64).
After i run .exe on the server then writes the following error:
Could not load or assembly 'MySql.Data'
..etc for all dependencies.
I tried to run just the .exe file (i didn't copy the whole Release directory) on a few PC and it is working well. All of them Win 64bit.
On the server, .exe only work if i copy the whole /Release directory.
I also build and release app with 'Any Cpu' option.
Any tip why i need to copy the whole /bin/release directory to run .exe?
Why not enough just the .exe file?
Many thanks!

The exe file doesn't contain the used dlls, just references to the dlls. That's why they are in the release directory and the reason you need to copy the whole directory.
Kind regards
Bernd

Related

Confusion with emgu.cv x86 folder

I developed an c# application using emgucv for face detection. According to emgucv documents folder "x86" or "x64" (depending on platform for which application is running) are need to be kept parallel to executing exe. So i did accordingly and run the project, application works just fine on my machine.
If I release this c# application along with all the dependent dlls and "x86" folder and copied to an windows 7 machine, after executing the application i get error Unable to load DLL 'cvextern' : The specified module could not be found. (Exception from HRESULT: 0x8007007E)
This is what i tried to solve the error:
I copied all the DLLs from folder "x86" to executing folder (i.e outside to x86 folder) and now application runs without any error.
So I am in confusion whether to keep x86 folder in executing folder or content of x86 folder. As per my observation both are working but what is recommended?
Normally the cvextern.dll file is located in the following folder:
project_folder\bin\x86\Debug\x86
project_folder\bin\x86\Debug\x64
The same goes for the x64 version:
project_folder\bin\x64\Debug\x64
project_folder\bin\x64\Debug\x64
The folder can also contain other files, e.g. opencv_ffmpeg310.dll. The Emgu.CV.World.dll and similar DLLs are located in the Debug/Release folder (one folder up).
Not sure which version of EmguCV you are using, I am using 3.2 so everything is built for x64. When I distribute my application, I create a x64 folder in the folder where the exe lives. In this x64 folder I put ALL of the DLLs from the EmguCV distribution. On my machine EmguCV lives in:
D:\Emgu\emgucv-windesktop_x64-cuda-tbb-ipp-icc 3.2.0.2682
So from the bin\x64 folder I copy everything to where the application exe is.
Doug

File getting copied to SysWOW64 instead of System32 while installing INF thru Installer

We have INF file which installs one .sys file to windows drivers folder. Scenario is as follows:
1) Installing the INF from File Explorer. Right click on INF file and click on Install. In this scenario .sys file gets copy under Windows\System32\drivers folder.
2) Created console application to install using RunDll32 / CMD under process object and install the INF file. In this scenario .sys file gets copy under Windows\System32\drivers folder.
3) Created x86 installer program having installer class to install using RunDll32 / CMD under process object and install the INF file. In this scenario .sys file gets copy under Windows\SysWOW64\drivers.
Our objective is to copy .sys file under Windows\System32\drivers folder irrespective of 32/64 bit flavor windows operating systems like WinXP, Windows7, Windiows 8/8.1/10.
Windows Installer (MSI) installs insist on installing 32-bit components in an x86 setup to the 32-bit locations. Attempts to direct 32-bit files to 64-bit locations will result in redirection. A 64-bit install can install to both.
Different MSIs are required for different architectures:
https://blogs.msdn.microsoft.com/heaths/2008/01/15/different-packages-are-required-for-different-processor-architectures/
and see in particular the WIN64DUALFOLDERS log and the accompanying remarks.

Difference in C# release, standalone exe or click once installation

I am using Visual Studio 2010 and I'm writing in C# (console program). I used to output a standalone .exe file from the debug folder (just copying the single .exe file to the client computers).
Now, it happens that different clients needs a different connection string. My solution was to copy the .exe file and also the .exe.config file from the debug folder. Modifying the config file will then directs the program to use different connection strings.
The concern is:
How about the other files in the debug folder, should I be copying them to the client computer as well? (e.g. .exe.manifest or .vhost files? )
Or shall I release the program into click-once file and install them into the client? But it would be quite troublesome and time consuming to install and uninstall the program on many computers (during version upgrade), also more complicated to call the program from bat files?
I used to just use the .exe file from the debug folder. But when I found out that the .exe actually reads from the .exe.config, I wonder sole use in the .exe would result in leaks in the program?

How to setup System.Data.SQLite.dll

Have I an application using sqlite...
Ive tried this:
installing via ClickOnce Application setup (it works)
I Put SQLite.dll file together with .exe in the same folder. (it works}
hmm the folder with an .exe only (not working)
What I mean is when you build the project and get the .exe on the folder \bin\Debug and move it somewhere then when you run the app errors will not occurs.
I wondering if there's a way that i can run even without installing ClickOnce Application setup?
I thinking of setup the SQLite.dll on specific path reference? Is it possible to do that?
-thanks
System.Data.SQLite.dll is not part of the standard .NET Framework so it does not get installed in the GAC of the client machines when .NET runtime is installed at first.
that's the reason why you should have this dll referenced by your executable, distributed together and in the same folder as your exe is deployed.
or you could distribute it somewhere else like in a sub-folder of your application setup and have proper entries in the configuration file or in the .NET C# code to specify where assemblies not found in the standard locations have to be loaded from.
You can use Nuget to get the package installed. For my case, it automatically created 2 subfolders for me, which is x86 and x64, I just followed the folder structure in the bin folder, and it worked fine for my case.

How to install windows service using Inno Setup?

In VS2010 I have solution with windows service project and some other 'helper' projects. So in my debug folder there is an windows service application and couple of dlls.
I can install windows service by running application with parameter, so in Inno Setup I just do:
Filename: {app}\MyService.exe; Parameters: "--install"; WorkingDir: {app}; Flags: skipifdoesntexist; StatusMsg: "MyService is being installed. Please wait..."
My question in: It is necessary to pack all files from Release folder to my Setup file? I mean, in my Release folder are: DLLs from my other projects in app solution, Program Debug Database (.pdb) files, and XML Configuration file..
What files should be packed in my Setup.exe file?
You just need the *.exe files.
*.pbd and other are not needed there.
Only DLLs if nedded by your main project (service).

Categories

Resources