I have written a windows service application which is installed on my PC. There is a problem with it, so I want to debug that service.
Can you tell me how to debug the windows services?
Please read: http://msdn.microsoft.com/en-us/library/7a50syb3(VS.80).aspx
The easiest way to debug code that you've written as a service in .NET is to separate all the functional code from the service into a separate assembly and then create another project, as a console or WinForms application that uses the separate assembly to run the service code.
If you have Visual Studio on same machine, use it to list the process and attach a debugger to it. You can also use remote debugging but it can be a pain to configure.
The easiest way is to add System.Diagnostics.Debugger.Launch() to the point you want to start debugging. Visual Studio will need to be running as Administrator. When the code is executed, a dialog will pop up asking which instance of Visual Studio you want to use to debug. If you've got Visual Studio already open with the relevant project loaded, choose that one.
Related
I'm quite new to VS Code. I have been debugging DLLs for 3rd party applications earlier in Visual Studio but it seems all the tools available there are not available in VS Code.
What I have been doing in VS earlier is:
create, develop and build my DLL to the plugins folder of that 3rd application (with references to the 3rd party application's libraries)
add the 3rd party exe as another project and set it as startup project.
when starting debugging session, VS automatically launches/attaches to my dll, i.e. I can step through my code when I start the plugin inside the app.
I am able to successfully build the DLL in VS Code to the correct folder and it works (will show me the simple msgbox i am waiting for). However, when I try to debug it by attaching the debugger to the 3rd party app process, the debugger does not stop at the breakpoints. When I hover over the breakpoint during debugging (which is not red anymore during debug), I get the message "No symbols loaded for this document". I guess I'm doing something wrong. The .pdb for the DLL is in that plugins directory. Is this because the debugger does not find it? Honestly, I'm not very well in with the launch.json contents yet (no need to work with those in full VS). What is the best way (if any) to do this kind of debugging in VS Code? In case this is something that definitely can't be done in VS Code, please let me know, so I know I need to return back to full IDE.
It turned out I just had some issues in my launch.json. I am now able to step through my code and the UX is practically the same than that with full VS. Problem solved.
#vernou Thanks for the link anyway!
Im creating a windows service using vs2010. I have been following tutorials and steps online of how to create a windows service. There is one step that is holding me back. I have researched many things and they all say the same way to create it. When it comes to installing the windows service, it asks me to right click on the grey area of service1.cs(design) and click add installer, however on my visual studio 2010 I do not have this option.
I have only seen one other person write on the internet that they have this problem and they said they ‘repaired the install’ to fix this, I carried out the same process but the option did not appear.
Please help!!
The best way to do this is to open the Service1.cs in design mode. Then, Right-click in the designer and select the Add Installer option. This adds a ProjectInstaller component along with the necessary assembly references. The ProjectInstaller component, in turn, has the service installer and service process installer added automatically.
The way Visual Studio offers windows service creation is just a whole lot of pain to work with.
I am going to suggest an alternate solution, which I think you should try out.
It is a open source project called TopShelf which allows you to run the service code as a console application while coding and debugging and when you want to install it as a windows service you simply run the exe with an /install option.
Have a look at their quick start guide. It doesn't get simpler than that.
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.
I am in the process of learning C#. I downloaded and installed Visual Studio 2010 Express with C#. The problem is it has all these templates that are a little overwhelming at the moment: ASP.NET website, Library, WCF, etc.
I just want to code something very simple that takes input from the Console and outputs to it. I am making do with WCF but that's really inconvenient. It is faster for me to load up ideone.com, type my code there and compile than doing it from own my machine.
Is it even possible to create simple programs like that in C# using VS2010 Express?
Thanks everyone who answered. I installed Visual C# and now I can create console applications. But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?
You can create simple apps by choosing Windows Application (if you want a GUI) or Console Application (if you just want to take input from console as you describe in the question) as project types.
Regarding the question of the console window immediately closing, the quick-and-simple fix for this is to have
Console.ReadLine();
at the end of program execution -- it'll do all it needs to do, then wait for (any) keyboard input before closing the window.
"But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?"
Try running without debug mode (Ctrl+F5 or Shift+F5 or some other binding depending on your keyboard setting). The program will wait for you to press a key to exit.
If you want to output it to the IDE, you could use System.Diagnostics.Trace.Write, which writes to the trace output in the bottom on the IDE. I do not believe there is a built in stdout view in Visual Studio... but it seems like a great idea for a feature...
Are you there, Microsoft?
Visual Studio can be extremely overwhelming. What you should remember is that it's a tool for professionals, ultimately. However, if you want to make a Console app, it's quite simple.
Open Visual Studio
File
New
Project
Other Languages
Visual C#
Windows
Console Application
Done.
Yes, Visual Studio Express is a very good free tool for creating applications. Of course it doesn't have all of the features of Visual Studio, but I use it at home for several reasons.
What you want is the "Console Project" template
I'm trying to create a quick debugger, wherein I can attach my application to a running .net process and execute scripts from there. I'm using C#.
How will I do it?
Thanks :)
You can attach to a process in Visual Studio and use VS tools for debugging. What does your application do that would require it to be attached to other processes outside of VS?
http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx