How to handle win32 services in windows 2000 platform - c

I ve designed a win32 service in windows XP its working fine. but the problem i'm facing is that it's not working properly in windows 2000 platform. that is stopping the service restarting the service. is there any setting or need to change in code to be done.

Is it possible you have used an API that was new on WinXP?
For an interactive applications you would get a popup about an unresolved import, if I recall correctly for services these are recorded in the system event log.
If it is hanging, take process dumps and feed them into a debugger with symbols (both Microsoft's and yours) configured. That will show you the stacks of the threads, and allow you to check for deadlocks.

Related

VS 2015 won't break at breakpoint in web api project

I have a VS2015 solution with 2 C# projects. A WPF client, and a Web API server. I set a breakpoint in the Web API code. Then ran the WPF client in debug. The breakpoint icons in the source file changed from solid red dots to red circles. The debugger is not breaking at the breakpoints. What am I doing wrong?
You effectively have 2 applications and you're trying to debug both at the same time which won't work.
Make your API run in IIS then use a separate Visual Studio instance to attach debugging to that process ( you can find it running under w3wp ).
So you can do this effectively with 2 instances of Visual Studio, one for the client and one for the API.
You can also simply open the same solution with a second VS, and run the API from there then have the client hit the api on the same URL as the one being debugged. It is a bit strange to use 2 Visual Studio instances but it does the job quite well.
Use whichever method you're more comfortable with.
I'm not 100% sure, but I think it is probably because you are just debugging the client. I had the same difficulty getting to the code of a WCF service recently. As I understand it (and I'm no expert, so people who know better feel free to correct me if I'm wrong) basically Visual Studio won't peek into the server code while you are just debugging the client. I presume that when you run the client, you also have the server running at the same time?
I think the best way to deal with this is either to start your client, and then attach the VS debugger to the server process (see https://msdn.microsoft.com/en-us/library/3s68z0b3.aspx), or to run both the client and server programs at the same time when you start the debugger (https://msdn.microsoft.com/en-us/library/ms165413.aspx).
Hopefully this helps :)

IIS related System.ExecutionEngineException

After too many hours of research I have come up with nothing to solve this problem.
I am running a WPF program in an .xbap page file being hosted on internet explorer. Running the project in Visual Studio 2010 works just fine and generates no errors.
I want to be able to host the webpage on IIS 7.0 and to browse to it with a windows forms application. To test this I created a new website on port 80 in IIS manager. I then published the project to the local website folder and added the autogenerated project certificate file (projectName_TemporaryKey.pfx) to my Trusted Publishers and Trusted Root Certification Authorities.
My problem is this: whenever I try to browse to the file with internet explorer or with my windows forms program, the wpf program stops working. When pulling up the just-in-time debugger, I am informed that there is a System.ExecutionEngineException but am given no source code, no stack trace, and no data outside of an empty Dictionary enumerable. My guess is that this might have something to do with the database call made in the program to another machine, but I can't prove that.
I've tried several things to solve this including repairing my .NET 4.0 framework and altering permissions but nothing seems to be affect the error.
Does anyone know of a way to get more information on this error, or perhaps a step I may have missed when publishing this project?
Thanks very much.
Some things to check:
Windows event log often includes additional exception information (although usually in an awful format)
Output some trace information from your application so you can follow what's happening
Try attaching a debugger to the WPFHost and then stepping through the code

Registering for USB insertion/removal notifications (Windows Service)

I am writing Windows Service which logs information on inserted or removed USB devices. RegisterDeviceNotification function returns valid handle, but SERVICE_CONTROL_DEVICEEVENT notifications still not come to service control handler function.
I used Tom Bell's "Detecting USB Device Insertion and Removal Using Windows API" and "Creating your own Windows Service" from Habrahabr.
I'm new to Services and Windows API, so could you please look at my code and tell what may be wrong? And if the code is correct, is there any pitfalls(?) connected with security restrictions or something like this?
[EDIT moved from answer]
The problem was not in code, but in incorrectly installed VirtualBox :)
The problem was not in code, but in incorrectly installed VirtualBox :)

How to debug and detect hang issue

I am testing my application (Windows 7, WinForms, Infragistics controls, C#, .Net 3.5).
I have two monitors and my application saves and restores forms' position on the first or second monitors. So I physically switched off second monitor and disabled it at Screen Resolution on the windows display settings form. I need to know it is possible for my application to restore windows positions (for those windows that were saved on the second monitor) to the first one.
I switched off second monitor and press Detect to apply hardware changes.
Then Windows switched OFF the first monitor for a few seconds to apply new settings. When the first monitor screen came back, my application became unresponsive. My application was launched in debug mode, so I tried to navigate via stack and threads (Visual Studio 2008), paused application, started and did not find any thing that help me to understand why my application is not responsive. Could somebody help my how to detect the source of issue.
Download the Debugging Tools For Windows then run adplus in hang mode. The with the resulting .dmp file open in windbg and invoke:
!analyze -v -hang
You should provide more information about what you saw in the call stack and threads windows. Which threads were running? Did you see anything that was waiting in a sleep or join? Have you tried naming your threads so that it's clearer as to what's going on when you pause (though not necessary since you can get this info from the call stack anyway... it's a convenience thing).

WPF application visiblity afte remote desktop

i have a WPF application that sits on top of all other windows. 99% of the time it works perfectly however if i dial into my computer from another location using remote desktop and then close the connection and go back to the original computer, my application is not visible. checking the running processes i can see that it is still running however its not visible at all. I assume it has something to do with the remoting but i was wondering if there is some code i can run say every 20 seconds that sits on its own thread that checks whether it is visible and if not will execute some code whether by pInvoke or .NET to become visible again. Any ideas?
Make sure to upgrade to .NET 3.5sp1. There were some changes with remoting which lead to WPF applications being sent as bitmaps in remote desktop in all situations.
In earlier versions of the framework, there were problems with WPF applications causing very odd behavior when combined with remote desktop.
Another idea - make sure you're using the latest and greatest versions of your graphics drivers from your graphics card vendor. WPF makes heavy use of DirectX, and this could potentially be a driver bug preventing the context from resetting appropriately.

Resources