Project exe build doesn't work - c#

I have a problem in my visual studio or my computer that I can't figure out how to solve.
This is the situation:
I wrote a program and when I tried to run it from the .exe file, it didn't work. From debug, the program worked properly but if I tried to open a second instance of it, it didn't work.
In both cases, when I opened the second instance, or open the .exe file, the process of the program opened and didn't work (kept loading, or in the second debug instance case it got the VS stuck). When I tried to close the process I couldn't, even after closing visual studio task. The only way was to restart my PC, witch I did a lot.
After that, I tried to run the program on another computer and I found out it worked well.
I came back to my PC to try to solve the problem. I uninstalled VS13 and installed instead the VS15.
I opened a new WPF project. First thing i did was build it and open the .exe and it still didn't open!
This is my case guys. I would love to hear information on this problem, why it happend and how to solve it.
My PC is running Win 8.1 pro x64 operating system.
I found this that resembles my case:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/fbae61b4-47f1-4074-9261-505ebbd8d459/cant-run-visual-studio-2012-generated-exe-files?forum=vcgeneral
Thanks!

The soultion to my problem was simple, i can't believe i didn't thought of it before. thanks to the first comment.
Disabling avast anti-virus solve the problem, the exe of my new and my original program is working fine.
Now all i need to do is find a way to make it work with the anti-virus working.

Related

C# Run my visual studio executable as administrator

Hi i have created my visual studio program and if i run it as normal it works perfectly. But the problem comes in when i create a setup installation for this program. It successfully installs my program but i cannot get the program to run as administrator and thus my sql statements wont work. Any suggestions on how to fix this problem?
It is hard to pinpoint the fault but I have a feeling you have asked an XY problem question where running with and without elevated privileges (often wrongly called administrator). Making an installation program an installing probably has nothing to do with it. Maybe you are starting VS with elevated privileges without thinking about it?
Try to start the program directly and not through VS. Find the output folder (yourproject\bin\debug\yourprogram.exe) and run it. Does it work properly? Then it works.
Now try to start it with elevated privileges (admin) (ctrl-shift-enter or ctrl-shift-doubleclick). Does it work as it should? If it does, your problem has nothing to do with privileges.
So then you might have side effects by the installation. An installed file is in another directory. Do you have hard coded relative paths?

The process cannot access the file 'CustomTabsClient_CustomTabsCallbackImpl.class'

I've upgraded my Windows to 10.0.16299 (latest) and my Visual Studio to 15.5.1 (latest). Since then, I am seeing this error message when I clean or build my Xamarin solution containing an Android project:
obj\Debug\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java:4:
error: error while writing CustomTabsClient_CustomTabsCallbackImpl:
obj\Debug\android\bin\classes\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.class
(The process cannot access the file because it is being used by
another process)
I figured that the locking process is Visual Studio itself after I tried to run and debug the app.
The issue appears no matter whether I want to run the app on an emulator or a connected real device.
There's lots of advice what to do when a process locks a file including SO such as the famous the process cannot access the file because it is being used by another process. However, all provided answers don't help as Visual Studio itself locks the file and the only workable workaround is to restart Visual Studio - that's not a solution.
What is causing this file to be locked? Any idea? Any advice?
Sometimes it helps to kill the MsBuild.exe. Also, you could find other solutions such as described here: Xamarin Android project cannot build....
Basically, it seems to be a problem with Studio 2017 Version 15.5. It will be fixed with the next versions probably.
Darn it, my suggestions won't fit in the context of a comment, so here goes:
Sounds like the process being debugged, or the emulator hosting the debugged process, itself, has not fully closed down, and is in a hung or semi-hung state. Have you checked the process manager to see if this is the case? You may want to to try adding Environment.Exit() to see if this helps come back to a good state.
Another thing to check is, whether your access levels are the same between the two machines. Check not only the PC, but also at the emulator as well. Check everything, and ensure the access levels/modes are identical.
Finally, try running VS 2017 in administrator mode, and see if the problem persists. It's entirely possible that the level of access that you used to run pre-Windows 10 is different in the Win10 world that you live in, now.

Avast blocks/deletes wpf .exe file when building in release mode visual studio 2013

I'm developing some WPF application and everything was working just fine, but suddenly I got this annoying error which says:
Could not find file 'obj\x86\Release\MIS.exe' avast wpf
So this happens when I'm building my project in release mode, and what causes it is avast anti virus which treats my .exe as malware. When I disable avast everything builds fine, also when i set this file to avast exclusions list also everything builds fine. This doesn't completely solves my problem because when I try to run this exe on another computer I get the same anti virus problem and my program can't be run.
What could possibly cause this type of problem and is there any other solutions for this? I just need to make this program to work on many computers because this application is meant to be used by multiple users.
Just to state that I don't get any errors when my debug mode is set to "Debug".

Could not launch xxx.exe. Previous attempt to profile the application finished unsuccessfully. Please restart the application

I'm having the exact same problem as outlined in this post:
Could not launch xxx.exe. Previous attempt to profile the application finished unsuccessfully. Please restart the application
All the Profiling methods give the same error on my system. The type of project I'm trying to profile is XNA/C#.
The provided solution to that problem is the only solution I can find using Google but it does not apply to me as I do not have Symantec anti-virus. Also, there are no instances of the SysPlant registry key (as mentioned in the above link) on my system. I have tried disabling all anti-malware and anti-virus software on my system but still get the error. Does anyone else have any other suggestions?
I had this issue, yet bizarrely it only affected one Visual Studio solution. Using the profiler with another Visual Studio solution worked fine.
I tried:
disabling Symantec
uninstalling VMware Player
but neither worked.
In the end I amended the registry, setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SysPlant\Start to 4 and rebooted, it then started working.

C# WinForms App won't run on Win7 after Building

I have a program that I built that reads and writes files. I built it in Release mode, then tried to run the exe on Win7. At first, with troubleshooting on, Windows simply told me the application closed and it was looking for a solution. After a few seconds, the dialog would disappear and show nothing more.
So with some significant effort I got the debugger attached to the process, but it was only showing me disassembly, which tells me that the error taking place wasn't in my application code, but in the framework somewhere.
The strange thing is that when I let the debugger attach, then press "stop" in VS, and exit the debugger, the program actually runs at that point!
So now I'm stumped. I have an application that builds, that seems to be having a permission error when I run it, but if I let the debugger attach then close it, it runs, and there's no Exception to really look at.
How I troubleshoot this issue?
Edit: Responding to Merlyn:
It's a custom app written from scratch in c#. The only dependency it has outside of core .NET namespaces is the Ionic.Zip DLL.
Visual Studio 2008 (Writing in C# 3.5)
Windows 7 - Home Premium, v6.1 build 7600
CPU - x64 quad core
CPU are you compiling under: Any CPU
I haven't tried it on another machine or a different version of VS.
Edit: I was able to try the compiled version on another win7 computer, and it worked without issue, so it looks like a security (?) issue on my computer only.
Try it in the debugger with Just My Code disabled and Native Code enabled, then check the call stack.
Also, what happens if you run it directly in Visual Studio?
Uncheck Enable Visual Studio Hosting Process in Project Properties and see whether it still works in VS.
I'd suggest sending the issue to Microsoft support. Especially with the data given here, you will have an easy time convincing them it's their problem. You might need an MSDN subscription for that.

Categories