Program works only in Visual Studio - c#

I've written a program that does extensive use of EasyHook. The program works just fine if I run it from Visual studio ( either in debug or release mode), but it stops working ( or better, it stops hooking) if I run it from the release folder.
The question is simple, why? I run both visual studio and the application with the same user, on the same machine, so there should be no difference...

check in your debug folder if you have any files that are not inside release folder (like .dll and so on) if so copy them to release folder! and if working then, then you probably use some external dll's or some references something like that... and you will also have to include them to your setup project!

I run both visual studio and the application with the same user, on the same machine, so there should be no difference
I can make a random guess, since you don't provide much detail, and no error messages in your question.
Visual Studio 2008 and 2010 runs elevated (if I recall correctly).
If you have not disabled UAC, then you will need to run your application as an Administrator.

Related

WinRT c# compiled to exe but does not run outside visual studio

Hey all I am pretty new to the "old" WinRT (Windows Runtime) framework and I am unsure about one thing so far. How do I run the app outside of Visual Studio? In Visual Studio when ran using "Local Machine" it compiles and runs just fine. However, if I try the .exe that it produces outside of Visual Studio then nothing happens - no error and no app screen...
Like I said, in Visual Studio it compiles and runs:
So when I go and execute the NitroCarEntertainmant.exe outside of Visual Studio then nothing happens. What am I missing that seems to be something that it needs to run? I know a store app has a extension of .Appx so not sure if I have to package it up in some way or if this .exe can work - I just don't know how to make it work myself - with some type of trick/hack/bypass?
Help would be greatly appreciated!
You need to create a package and install it before running. On Windows 8 and 8.1 you'll need a developer license for this but on Windows 10 you can install it normally however you added to sign it with a certificate and import it before installing.

Do we need to add the files in the debug/release folder to create a setup in Visual Studio?

I have created a setup file for my Winform project in Visual Studio 2013 but it won't run after the installation. When I use debug or release mode in Visual Studio, it will run.
A closer investigation, I found out that there's lot's of .dll, .config, .cs, .bin, .manifest in the debug folder as well as the release folder. I think they are the files created when I run debug mode or release mode.
Do I need to include all these files from the debug/release folder to the setup file system when I create my setup? Any idea how to check why my app won't run?
The files in the Debug folder must not be distributed, it is against the terms of you EULA for Visual Studio.
You need the release files and unless you are running on the build machine you may need some extra dependencies, You will be told about these in the error messages that are displayed.
More than that I can't help you with, because you haven't said what the error is, unless its no error in which case check your shortcut.
If the Application runs fine in the Debugging Mode of visual studio, then it means that you are not creating the setup file properly. You have to manually add all files that appears in the
../bin/Debug
folder of your project to after adding the primary output.

Program doesn't work outside Visual Studio

I use unmanaged dll with P/Invoke in this app, and I always tested it inside Visual Studio (with debug mode on x86 CPU because the dlls are only x86), and it works just fine. But when I just start the exe manually after some time (probably at the first operation with those dlls, but I don't know exactly) it says the exe has stopped working, and it starts checking for solution (I use Visual Studio 2013 on Windows 8.1, if that matters). I tried to add the dlls to the project as existing item, but that doesn't help. Also I know, that it's not because it can't find those dlls, cause if I delete them, it doesn't crash, just freeze without any error message. Shouldn't it work the same from Visual Studio as manually started?
There is also a weird bug when I run from Visual Studio: everything's work fine, but sometimes Visual Studio just suddenly stops debugging, as if the program were closed and the GUI of my app freezes, and I can only close it by closing Visual Studio (as I close it, the GUI disappears). Maybe it's a totally different problem, but it can be connected.
Edit:
Here's the project on github, if somebody could check it:
https://github.com/geiszla/CycriptGUI
Some news: If I run it with Ctrl+F5 it also crashes. What's the difference between F5 and Ctrl+F5, that can cause this problem?
Searched all over Google with no real simple answers. Here it is folks(at least it worked for me and is simple):
When you run the console app in Visual Studio, look at the output window at the bottom, get the location of the ..\bin\Debug\*.exe
Copy the *.exe and the *.config to your desired folder, run it, it should work the same way in Visual Studio.
Thanks for every help, my problem was solved: I called an unmanaged function with only 2 parameters, while it had 3. However I still don't understand why it worked with debugging mode, and not without debugging.

dll is being used by another process

I am creating an extension in Visual Studio 2012 and keep having this error which is getting rather frustrating.
The way I have dealing with it recently is that I have to go into the add-in manager before I start the extension, un-check all boxes for the add-in, close out of Visual Studio, reopen Visual Studio, start the add-in debug, re-check the add-in in the add-in manager, then restart the debuging. As you can imagine this is rather time consuming and is annoying. It also only works about 70% of the time. It occurs also when I try to build or rebuild the project and no other Visual Studios are running. Is there any way I can prevent this from happening or is there a way to fix this error?
As you're discovering, you shouldn't install an extension from the bin folder while you work on it.
Remove the extension entirely from your main copy of VS, then create a separate test environment by running devenv /rootsuffix MyTest and install the extension there.
You should then debug the extension from that instance and kill it when you're done.

WPF DotNET Application will run in debug mode, but .EXE will not run

I wrote a WPF application in C# using VS 2010. The application will run fine in debug mode using Visual Studio, but when I go to run the .EXE from the bin\release folder, nothing happens. I do not get any error messages from windows and there are no errors or warnings in VS. I have tried to build, rebuild and clean the solution (in every possible order) with no luck. My solution contains 2 projects, both of which use .NET 4.0 framework, and I have .NET 4.0 installed on my PC. I have tried on both XP and Win7 and still nothing.
I also just noticed that the output from Debug when I run the application in debug mode says: "Cannot find or open the PDB file" after each .Dll it loads.
I am compiling to the Release folder every time, but i did try changing it to the debug folder and clean/rebuild just to see if that would make a difference, and it didnt, so I changed it back, tried it again, and still nothing.
Any Ideas?
Here are a couple of ideas that come to mind
If you are on a x64 machine, try changing the application from being AnyCPU to x86. This the mode that applications default to in debug mode and it's possible an issue running in x64 is causing a problem in release builds
Possible the Release binaries are out of date. Delete the binaries from the Release folder, rebuild and run the newly generated runs
Run the release build under the debugger in Visual Studio and see if it till crashes
I was experiencing the above issue too, however none of the other solutions worked for me.
My Application logs in Event Viewer listed event ids 1018 and 1022. This appeared to be bizarrely related to an ASP.NET 2.0 dll (bizarre; as this was a blank WPF project only). The logs contained messages like this:
Windows cannot open the 64-bit extensible counter DLL
ASP.NET_64_2.0.50727 in a 32-bit environment
In the end it turned out to be resolved when I disabled my anti-virus. I had read that this resolution worked for someone with McAfee; and it also worked for my environment, which has Avast.
I assume you tried on a machine that doesn't have visual studio installed, and also none of the components you are using for development.
You have only one option: start the application with a debugger on the machine that causes problems and check for exceptions there. (use WinDBG for example - it's light and easy).
This looks like a problem with missing dependencies, but might be something else also.
The Debugging Labs should give you enough information on how to use windbg to find your problem:
.NET Debugging labs
Also use this:
WinDBG Cheat Sheet
(JaredPar) answer looks right (x64), but if not try right clicking on the EXE and running in admin mode for win 7.
I had a very similar issue.
Check out this setting on your App Pool entry:
Go to Advanced Settings.
Change 'Enable 32-bit Applications' to 'TRUE'.
This worked for me!
I'm going to go with a wild guess that:
Either you have some odd corruption in your .NET Framework installation
There is some debug/release-specific code using #if DEBUG or the such that is substantially different to cause issues.
You have not compiled recently into Release yet (Try changing it to Release before compiling your latest code and make sure you get no errors).
Those are the only things I can think of off the top of my head.
I had run into a similar issue, I was missing a custom folder in the release mode I was referencing in the constructor. Adding the folder to the release fixed the problem.

Categories