How do we specify a debug target to Visual Studio - visual-studio

here is my program
program hello
print *, "Hello World!"
end program hello
and it says to me
visual studio cannot debug because a debug target has not been specified

The way this normally happens is that you chose the incorrect project type - for example, a library instead of executable. If your project is properly building an EXE and you still get this error, right click on the project, select Properties. Then on the Debugging property page set the Command property to $(TargetPath). Otherwise, create a new project of the correct type (for example, Console Application

Related

Visual studio doesn't let me select project for startup

I have a solution structure like this:
Normally, I would like to debug 'SoundStudio.MainWindow' but it does not let me start that project:
Any Ideas?
You have to right-click on SoundStudio project, then select "Set as Startup Project"; in this way you should be able to launch your program and debug it.
Currently it seems you have set WaveFileLib project as startup project (please note the bold white text for its name); from the name I guess it is a library and an error message like "A project with an Output Type of Class Library cannot be started directly" should be prompted out when trying to debug it directly.

TFS API DownloadFile( ) functions cause exception when debugging

Whenever I call Item.DownloadFile(string localFileName) or VersionControlServer.DownloadFile(string serverPath, string localFileName) I get a FileNotFoundException whenever I try to debug in Visual Studio: Could not find file 'C:[Project Path]\bin\Debug\[ProjectName].vshost.exe.config'.
When I build the application and run it outside of visual studio there is no problem calling these functions. It works perfectly fine. Anyone know what could be causing it?
Before you ask, no, that file does not exist. I'm not doing anything with a config file, I don't need or want it to exist. I don't understand why it is even trying to access that file when I debug. When I run the application outside of visual studio that .config file still does not exist but I get no exception because it's not trying to access that file.
Also, it is not a vshost problem either. When I uncheck "Enable the Visual Studio hosting process" I get the same exception except when debugging but the file name changes from "[ProjectName].vshost.exe.config" to "[ProjectName].config"
Currently, when I want to debug this project I have to put a MessageBox.Show( ) function right after every call to DownloadFile( ) and run my application outside of visual studio. When that MessageBox is displayed then I can use attach to process and put a break point on the next line after that MessageBox, click OK on the messagebox and then it will catch the break point. But when I'm downloading files in a loop and want to debug the loop it's extremely annoying and time consuming to attach to process after DownloadFile is called, stop debugging before the next DownloadFile is called, attach to process again after DownloadFile is called, and keep repeating that all day long.
I'm not totally sure, but looks like it has something to do with the current path and the Workspace where you download the file to.
If you don't explicitly specify the workspace, the TFS API will try to determine it from the current path of your application by looking if that path is declared in a Workspace as a Mapping.
If I remember correctly, you can download an item from a Workspace object (or specify the Workspace in the operation), try to modify your code to do that and see if it's better.
You can also try to change the current path of your debugging session to something "inside a Workspace"

Debugging UDK using nFringe in Visual Studio 2005

This is a pretty niche question, so I am not expecting a huge response...
Basically, I am learning how to use the UDK by following some tutorials, namely this one:
http://forums.epicgames.com/showthread.php?p=27043379#post27043379
So far everything is going pretty well. The only real hangup I've had is getting everything to work in Visual Studio 2005 using this nFringe plugin. For a long time, couldn't get them to work at all. I've gotten into two or three chapters of the tutorial, and I've managed to use Visual Studio to edit the code, but I can't build the scripts within VS; I have to go to UDK Frontend to do that. And worse still, I can only really use Log commands in the unrealscripts to debug anything.
So my question is this: is it even possible to configure these tools in a way that I can put breakpoints in VS and have them be caught when I test the game? I feel as though I don't have something setup correctly.
Yes it is possible. Here are some info which might be useful to you.
First, both your .sln and your .ucproj files must be located in Development/src. Then, under visual studio, right-click your project (.ucproj file in the solution explorer) and open its properties.
You must set, under the General tab:
Target Game: UnrealEngine 3 Mod
UCC Path: ....\Binaries\Win32\UDK.exe
Reference Source Path: ..\Src
Under the Build tab:
check "Build debug scripts"
Under the Debug tab:
Start Game Executable: ....\Binaries\Win32\UDK.exe
Load map at startup: the name of your startup map, without path nor extension
Start with the specified game type: put your GameInfo class used for your mod, ie. MyMod.MyGameInfo
Disable startup movies can be checked to gain time at launch
Enable unpublished mods must be checked.
In your command line, the parameter -vadebug specifies that the breakpoints will be enabled.
After that, you must be able to build your script from Visual, and launch your game by pressing F5.
Breakpoints should work but you can't put them on a variable declaration, you have to put them on a function call, an assignment or a condition statement.
Hope this will help.
I havnt tried using breakpoints yet but I know its possable to build with nfringe and visual studio . You need to add a line to the
udk game / config / udk engine .ini
search for
editpackages
exactly like that , then youll see a block like this
EditPackagesInPath=....\Development\Src
EditPackages=Core
EditPackages=Engine
EditPackages=GFxUI
EditPackages=GameFramework
EditPackages=UnrealEd
EditPackages=GFxUIEditor
EditPackages=IpDrv
EditPackages=OnlineSubsystemPC
EditPackages=OnlineSubsystemGameSpy
EditPackages=OnlineSubsystemLive
EditPackages=OnlineSubsystemSteamworks
then add your own line pointing to a folder named what ever you want but make sure it has a folder in it named Classes and it has the uc files you wnat to compile in it
ModEditPackages=MyTestProject
if you used that line then you are tellign udk you have a folder named
MyTestProject
located in your development/src folder and you want it to compile everything in there

Redirecting 'nunit-console' output to the Visual Studio output window

I am testing an F# project using NUnit. On the debug tab of project configuration I have set the debugger to use an external program which is nunit-console here and the working directory to the debug folder of my project. I prefer using nunit-console with the debugger since the GUI version doesn't hit the test file's breakpoints.
When I debug the test the console window appears and disappears and there is no chance to read the output. I have tried Console.Readline(), but it doesn't work because when I directly run the test from a terminal using nunit-console, it fails due to this command.
Is there a way to redirect the nunit-console output to the Visuals Studio's output window?
UPDATE: I could use Thread.Sleep() to delay the nunit-console.exe when I run the test from the console. But from Visual Studio it doesn't happen so I am pretty sure that nunit-console.exe fails to read the test file when the command is issued by Visual Studio. Still, it would be very nice to be able to read the console output, thus the redirection is still desirable.
Either use Tools->Options...->Debugging->General:"Redirect all Output Window text to Immediate Window" and then make sure that the "Immediate Window" is visible with Debug->Windows->Immediate.
Or use NUnit's "/wait" command line option.
Unless I am missing something, you should be able to hit all your breakpoints with the GUI as well, set the startup project to nunit.exe and pass the name of your test DLL as a command line parameter. You will hit the breakpoints in Visual Studio, and your print statments will be in the GUI's output tab.

Trace in Visual Studio Testing (Migrating from NUnit)

In NUnit, I'm used to writing Trace statements in the test, and having them show up in the trace tab of the NUnit gui.
On a new project, I'm moving to the built in Unit Testing in Visual Studio Professional Addition, which I believe is an interface to mstest.exe.
Test Code:
<TestMethod()>
Public Sub TestPagesInheritFromBasePage()
Dim webUI As Assembly = Assembly.GetAssembly(GetType(WebUI.BasePage))
Dim badPages As New List(Of String)
For Each t As Type In webUI.GetTypes()
Debug.Write(t.Name + ", ")
Trace.Write(t.Name + ", ")
If t.BaseType Is GetType(System.Web.UI.Page) Then badPages.Add(t.Name)
Next
Debug.Flush()
Trace.Flush()
If badPages.Count > 0 Then
Assert.Fail("{0}: do not inheriting from BasePage", String.Join(", ", badPages.ToArray()))
End If
End Sub
I'm getting a failure, so I know the Debug.Write and Trace.Write lines are executing.
I've read through the MSDN docs on writing these tests, and I can view the trace output if executing at the command line, via:
mstest.exe /testcontainer:mydll.dll /detail:debugtrace
However, I can not find the trace output when executing the tests directly in visual studio. Is there another preferred method of outputting information during a unit test, or am I missing an option to see trace info in visual studio?
Answer:
Both of the answers below (Console.Write and Debug.Write) worked, the results were in Test Results Detail (TestResult Pane at the bottom, right click on on Test Results and go to TestResultDetails). Also, I set Debug and Trace constants in project properties.
Try using Console.WriteLine() instead. I use that in my unit tests and it works fine - it displays text in unit test result output window.
Usually I use this method to print something in the output window of visual studio:
System.Diagnostics.Debug.WriteLine("Message");
To see the results double click on the test in the "Test Results" window (Accessed from the main menu item "Tests" >> window menu >> Test Results)
All earlier answers are actually correct but require more or less mouse-clicking.
If you would like to see the output immediately without an extra click, just add the columns Debug Trace and/or Output (StdOut) (whether you're using Debug.Write or Console.Write) to the Test Results pane through right-clicking on the test result and then 'Add/Remove Columns'.

Resources