C# exe running issue with EMGU CV - c#

I have been working on Microsoft Visual C# 2010 for an image processing program. The software uses EMGU CV 2.4.0. The program is very long (consists of 8 very lengthy functions) so i cannot post it here. Now, the program works perfectly on my pc. I have finished it. I can just run the exe file, and it works. My problem is that the .exe file doesnt work on another computer. Actually, I have 2 separate projects, But both are using EMGU CV. No error message shows to me when I run the first exe on another pc ( although it shows to me sometimes that ( project1 stopped working, windows is trying to collect information, this might take minutes ) but that's not always. Now the error message that shows to me when i run the second exe on another pc is (microsoft .net framework, EMGU.CV.CVInvoke exception error). then the exe work and a window appear ( which is expected ) but the real task of the program which is doing some image processing is not being done.
Note that both of the projects are windows applications output type.
Note that .NET framework 4 client profile is the target framework
I don't think this is .NET framework issue. Because I have tried to do a simple program and the exe file works on the other pc (it was just a simple streamwriter program which creates .txt) These are the EMGU CV libraries I'm using:
EMGU.CV.dll
EMGU.CV.GPU.dll
EMGU.CV.UI.dll
EMGU.CV.UTIL.dll
Just for your information, I have downloaded EMGU CV 2.4.0 on the other pc as well ( after failing in running it with putting the libraries with the .exe in 1 file ) but still nothing works. I have no clue what on earth can be the problem!
I don't know if this is useful, but the program uses SURFFEATURE example as the one in the EMGU CV but with lots and lots of modifications ( I have worked on it since the last Novermber) and basically it is a program for object recognition purpose.

have you installed the Visual C++ redistributibale on the machine, you are trying to run the file on?
If it's a x64 machine you will need the x64 version. But I would still also install the x86 version, just in case...

I know that this is an old question but..
If your OS is 64 bit you should use EmguCV x64 but if your OS is 32 bit then use x86 dlls. I built my solution as 'Any CPU' and it still worked.
Also as #Pogo the Jotz mentioned, you need to install Visual C++ Redistributable on that machine, same as on your visual studio version in which you compiled your exe file. The .Net framework also should be the same.

Related

monodevelop - working debug but not working release

I have developed a project with VS on Windows 10. Right now on Linux mint i am debugging the project with MonoDevelop and it runs just fine.
Let me show you:
However when i make a build and i go to the Release folder and then i try from the terminal to launch the program i have a problem. Let me show you first the files i have build:
Then i go to the directory with my terminal and i run:
chmod +x ./WorldServer.exe then i run ./WorldServer.exe
and i receive the following error:
I know that this is .exe file and maybe i have to build a different type of file. But i am not really sure what setting should i apply in my project to make a working build for linux.
As far as i know linux is using .so as extension for it's libraries. However it is generating .dll files. Can i change that? Can i somehow make my project to be "buildable" in the two OS Linux and Windows ?
The exception tells us, you need System.Management in your project. It isn't there.
Why?
Because Mono, according to there Road-map, doesn't support this:
The following do not map to operating systems other than Windows, and
we are unlikely to spend time to support them even on Windows:
System.Management
How?
System.Management is a library that only works on Windows. The MySQL connector driver has started to depend on this library and tries to load it per reflection.
I'm not into this whole MySql Progess but there is an open bug for it. Also there is a comment which says:
The last working version of the MySQL .NET Driver is 6.4.6
I hope this helps you.

How do I link to external DLL so that it will be recognized by Windows 8.1?

I developed WindowsForm application using C# with Visual Studio 2010, and I have external DLL (written using VC++). When I deployed it to Windows 7, everything works fine. However, on Windows 8.1, it installed fine and run fine, until the program needed to access the library function inside the DLL. It complained that it couldn't find the DLL (even though the file is in the same location as the executable).
This happened in Windows 8.1 only (perhaps with Windows 8 as well).
Did I link the DLL incorrectly perhaps?
Assuming that your DLL is a windows native DLL, one of two things is happening:
Windows is failing to locate the DLL
The DLL has other dependencies that are not available on the machine
To check, try changing the PATH environment variable to include the folder that your DLL is in. If the program runs then it's a problem with locating the DLL.
If that doesn't work then you'll need to do some more in-depth investigation to find out what is actually happening.
There's a guide here that shows you how to determine what is happening with your program using Process Monitor to find out what is actually failing to load. This might not be your C++ DLL, it could be one of the many dependencies for it.
The answer is the comment from Harry Johnston above:
Most likely cause: the Visual Studio 2010 Microsoft C runtime isn't installed on the Windows 8.1 machine. Or perhaps the C++ class library. Nothing to do with the OS version, except perhaps indirectly. You can diagnose this sort of problem using Process Monitor, look for file not found errors.

C# VS2010 program compiling + running on Linux MONO

I have a c# program I wrote. I want to run it on Mono on CentOS 6. What are the steps I need to take to compile it? I read some steps using xbuild which I could not get to work, some steps using gmcs, etc. Nothing working right now.
A simple and to the point guide would be good. I ran it through a Mono Analyzer and it did not give any errors for Mono, so it should be good to go.
Well you shouldn't have to special compile it at all as long as it doesn't have a GUI (meaning it's just a console app), or that GUI is a simple Windows Forms or GTK#. Mono will run a regular C# program on the console just fine. There is some quirkiness with Windows Forms, which was never fully finished, but generally you should just be able to compile using VS 2010, copy the dll's and executables to the system you want to run it on, and run 'mono myprogram.exe'. We run several older programs we have this way.
To run a .net program under mono all you have to do is to copy the .exe file with all depending dlls to the mono machine and run the application with:
mono myprogram.exe
if this doesn't work, something with your code doesn't work with mono/Linux.
As you mentioned in a comment, you got some IO errors, that could be because you trying to connect to COM1 or something like that. COM doesn't exist in Linux, as I'm sure other stuff doesn't either (I'm a very beginner with Linux ^^).
Maybe you should try to Console.WriteLine() at some points off your code. That's a good way to "debug" without debugger ^^

Program works only on some pc, DLL missing?

I wrote with VS10 the following projects:
a C# (.net 4.0) program which calls
a C++ unmanaged dll, which make use of boost::thread
a setup project which includes the C# executable, the C++ dll, the boost::thread dll and some other files. Moreover during the installation there is a check if the framework .net 4.0 is installed, and if not it will be downloaded.
The compilation (x64 for each of the three projects) is ok, and the program works on my pc (Windows 7 64bit).
I tested the program on some other computers (all Windows 7 64bit) and I noted that:
in the ones with VS10 and Boost the program works
in the ones without VS10 and Boost the program gives an error in the C++ Dll
I think the problem is that some boost Dll is missing. Am I right?
Or the problem could be related to VS?
edit:
I have to mention that the structure of the program is the following:
main form (C#) in which some parameters are set, then a backgroudworker calls
the C++ DLL which do its stuff and uses boost::thread
it does some computations
when it get some results, writes them on file
continue with its computations and so on
the main form has a filesystemwatcher which looks for the results file and do some stuff with the results.
Also, when I get the error, the main form correctly loads and the parameters could be set. The error happens when the backgroundworker starts his work (calling the C++ DLL).
So I'm quite sure that there is no problem with the framework installation.
Update:
It turns out that I forgot to include some DLLs in the setup project. Now, including them the error changed.
Now, at the same point as before (and on the same computers) I get another error:
BadImageFormatException: An attempt was made to load a program with an
incorrect format
I read this article, but I have set x64 in both C# project and in C++ DLL and the setup project has as TargetPlatform x64. Any idea?
VCRedist package is missing on target machine. It should be available in VS SDK directory. Also you may need to install .Net Framework on target machine (.Net Framework contains VCRedist package). If you don't have instalation files for those, they are available on microsoft sites i.e. VC10Redist for x64 is here
In such cases I use the tool Dependency Walker
Launch it and select your executable to discover the missing libraries.
It gives clues indicating what is needed to install then.
If your C++ DLL is dynamically linked to the CRT, then you have to deploy also the VC++ CRT DLL's, i.e. MSVCR100.DLL and C++'s MSVCP100.DLL on the target machine (they are already available on your dev machine, where you have VS2010 installed, so on that machine your C++ DLL loads fine; but you can't assume that on your client's machine the CRT/C++ DLL's are available).
There are several deployment options: you may want to read this documentation on MSDN.
I finally found the solution!
The C++ DLL needs the mpfr library for multiple precision floating point computations with correct rounding.
I was including (shame on me!) the incorrect version of the library (x86) and this was the motivation for the error:
BadImageFormatException: An attempt was made to load a program with an incorrect format
Then in all the computers (three different computers!) in which the program was ok there were both (unlucky and misleading coincidence):
Boost and VS10 installed and
a x64 version of the library in a folder contained in the Path environment variable.
So, in some way the program found the right version of the DLL.
Including the right version of the library in the Setup Project fixed the problem.
Thanks to Kamil Klimek, Stephane Rolland and Mr.C64 for their precious suggestions.

Compiling moonlight application on Mac OS X

I'm using MonoDevelop 2.8.5 and I'm trying to compile a moonlight application, but it fails. I created a brand new Moonlight Application Project and tried to compile it, but it fails with the following error.
Error: Framework 'Moonlight / Silverlight 4.0' not installed. (MoonlightTest)
In this question from October 2011 one of the developers of MonoDevelop states that is not possible to do this without some major hassle.
Is this still true with the new version(s) of MonoDevelop out?
If so, how can I compile Moonlight Application Projects in MonoDevelop if I'm willing to go through some hassle?
This is a bit of "psychic debugging" but I've run into it a lot in linux and imagine you might have the same problem happening on OS X. Is the compiler that Monodevelop is looking for exactly the same as the version you installed? It might be something as simple as the folder being called Moonlight1.3 vs Moonlight1.3.1. Look at the build output and see what version it is looking for then look in your applications folder (via terminal the app folder in the finder might hide the info) and check that they are the same.

Categories