I'm starting to use Xamarin Studio, and migrating from VS to it, but when I try to run a console application (the unique one loaded at the moment), fails and throws an exception in Console.Clear() (Supposing I can't do that in an integrated debugger), then i thought that one way to solve it was by compiling it and running it, like Visual Studio does, and Debug the application outside the IDE, but I can't figure out how. Could someone tell me how to solve this problem? Thanks.
EDIT: For any reason, it runs in the embedded window when selecting Release, but it can't read input, so it gets stuck.
You need to set the project option to have it run your console app in an external console:
Visual Studio For Mac:
Project Options / Run / Configurations / Default / Run on external console
Xamarin Studio:
Project Options / Run / General / Run on external console
You can fix this by running your program in a separate console window. It’s easy to do, although you need to follow the steps closely.
The first step is to bring up the project’s options window. You do this by finding your ‘Solution’ panel (normally on the left side of the Visual Studio window), and within that panel you much right-click on the project (this is pointed to by the “1” arrow in the below picture). Once that context menu appears you need to click on “Options”, which may be very close to the bottom)
Once the Project Options window appears, you should click on Run Configurations Default (next to the ‘1’ arrow, below), and then check off Run On External Console (next to the ‘2’ arrow, below)
Once that’s done you’ll need to click the ‘Ok’ button.
Everything should work fine at this point, but it’s always good to double-check: try running a program that asks you to type something and verify that it’s working correctly.
Related
I need to debug run a C# project using a different user. I found this link, However, it's old.
How do you debug a project as a different user in Visual Studio 2022?
The Launch Profiles doesn't have the executable field.
If you mean how to using the approach for a .net core project, here is the steps:
Click the downward arrow in the picture and choose "<project> Debug Properties".
In the dialog click the first button and choose "Executable".
Input the executable and arguments.
Select the new profile (in the first picture) and start debugging.
Note that with this approach you still need attach to the process, see the comments in this answer: https://stackoverflow.com/a/1287221/6196568
I have created a small program in C# WinForms that runs fine when I start it in Visual Studio 2017. But when I build the solution and double click the .exe, nothing happens, no screen appears, even the task manager doesn't see it. No errors. It's like it doesn't do anything! My only guess is that I built it wrong because I used Nuget to install newtonsofts JSON.NET in the solution. Do I need to do anything differently or should just building the solution work?
[solved]
today i learned the difference between the bin and obj folder, thanks to everyone for helping
Based on your comment:
it is in the obj/debug folder of the project
It sounds like you're running the wrong .exe. The obj folder is used for temporary/misc. files from the build process (see What is obj folder generated for?).
Instead, you want to run the exe within bin\Debug, if "Debug" is the configuration you're building for. You can see which configuration at the top of VS.
Like others have also mentioned, make sure that Newtonsoft.Json.dll is being copied to that output directory as well. Programs and their dependencies need to be together, generally speaking. Otherwise, your exe will not know where to find the JSON code it needs to function.
99% of the time, you should pretend the obj directory isn't even there.
If that still isn't pointing you in the right direction, run the app from a command window. Any exception should get printed to it and the window will remain open for you to examine (and this has the benefit of not needing any additional logging or exception handling code to see this error).
For example, I wrote up a bad application that get a NullReferenceException in a method called Test that is called from Main. As you can see, the stacktrace is easily visible, even though my app has crashed (credit to ColinM for bringing this up originally).
I believe that there's a problem with the startup module. Follow the steps below
Open your Solution in visual studio
Double click on properties
Select output type to Windows Application
Make sure to set the startup object as follows
I hope it helps
I think there is only one reason
There is a command line argument predefined in Visual Studio. Your application uses this argument to be executed, without it, it closes itself too quickly and you even can't see your application opened.
Right click on your project in VS -> Properties -> Debug and see if there is a value in command line arguments
exe and their supporting files should be in the bin folder. Do not copy only exe from bin folder and try to run it. It is a good idea to write some exception code to get the detail.
For future reference, yet another reason (that I have experienced) can be
System.Diagnostics.Debug.Assert();
statements. In my case, the program executed normally when started from VS but when I run it by clicking its .exe (created in the Debug Mode) then it hung/freezed. No exceptions, no printed logs. Frustrating. Then I checked the Windows Event Viewer (Our true friend). It explicitly displayed the problem and the culprit was a Debug.Assert() statement.
The lesson learned again: Check
Windows Event Viewer > Windows Logs > Application
especially when your app hangs/freezes/deadlocks or when no app logs are available.
I am trying to learn C# and have followed the instructions in this tutorial
I have created a project, added the controls to the design surface and added code to the button click event. When I get to the part which asks me to test the application, I click "start debugging" and I get an error message saying
There were build errors, would you like to continue and run the last successful build?
If I click no, nothing happens. If I click yes I get another error saying:
Visual Studio cannot start debugging because the debug target 'C:\Users\hp\source\repos\HelloWPFApp\HelloWPFApp\bin\Debug\HelloWPFApp.exe' is missing.
As a complete beginner I have no idea why this exe file is missing or how to fix it. Could someone point me in the right direction at all?
It's possible that your code has never compiled. Press Ctrl-Shift-B and try again (or look in the Build menu).
First: You should clean the project than Build project again.
Second: Run project by pressing F5
Executable file you can find in bin/Debug folder in your root of project.
I do not have VS now, why don't you rebuild (or rebuild-all) your project, and if successfully rebuilds check whether the executable file exists in that folder, and also check the release folder, if it is there then change rebuild option to debug, as far as i remember you will see a drop down, on the toolbar,
I'm starting to use Xamarin Studio, and migrating from VS to it, but when I try to run a console application (the unique one loaded at the moment), fails and throws an exception in Console.Clear() (Supposing I can't do that in an integrated debugger), then i thought that one way to solve it was by compiling it and running it, like Visual Studio does, and Debug the application outside the IDE, but I can't figure out how. Could someone tell me how to solve this problem? Thanks.
EDIT: For any reason, it runs in the embedded window when selecting Release, but it can't read input, so it gets stuck.
You need to set the project option to have it run your console app in an external console:
Visual Studio For Mac:
Project Options / Run / Configurations / Default / Run on external console
Xamarin Studio:
Project Options / Run / General / Run on external console
You can fix this by running your program in a separate console window. It’s easy to do, although you need to follow the steps closely.
The first step is to bring up the project’s options window. You do this by finding your ‘Solution’ panel (normally on the left side of the Visual Studio window), and within that panel you much right-click on the project (this is pointed to by the “1” arrow in the below picture). Once that context menu appears you need to click on “Options”, which may be very close to the bottom)
Once the Project Options window appears, you should click on Run Configurations Default (next to the ‘1’ arrow, below), and then check off Run On External Console (next to the ‘2’ arrow, below)
Once that’s done you’ll need to click the ‘Ok’ button.
Everything should work fine at this point, but it’s always good to double-check: try running a program that asks you to type something and verify that it’s working correctly.
I recently started experimenting with Xamarin and Mono C# on my Mac. I am used to working on Windows with Visual Studio so I find it cumbersome when every time I run my console application, a new terminal window and mono compiler terminal open up. And I have to manually close them. Is there anyway to get the output of my programs from a window or pane inside the IDE ? Or is there anyway to set it up so only one terminal window shows up ?
If you open the Project Options there is a Run on external console check box in the Run - General category which controls this behaviour. If you uncheck this option when you run a console application the output will be shown in an Application Output window inside Xamarin Studio and no external console window will be opened.
For anyone else arriving at this question who can't locate 'Project Options', the item is found in a drop down menu under the Project Tab (located at the top of the screen on the app's main nav bar). When a solution/file is loaded, the item is listed with your project's actual name, ex: 'MyProject Options' or 'MyProject&Options' (–it does not literally read 'Project Options').