I will answer more questions about readers this month. I will discuss issues such as Windows Communication Foundation WEB services running under a common user account and the use of classified technology and dual key control to protect credit card data.
Q: When I run a simple windows®communication Foundation service as a non-administrator, why can't I start?
A: The first thing I want to say is, it's nice to hear you test your code under a normal user account! This is an important aspect of the testing effort that developers should not overlook.
Now, for those who want to thoroughly identify this type of problem, the first way I recommend it is to start Filemon and Regmon, find records that failed to open file operations, or find registry entries that can be taken from the Sysinternals (recently acquired by Microsoft) Web site Www.sysinternals.com obtained. Unfortunately, these tools do not diagnose all the sticking points that may be causing the problem. Even the simplest WEB services, such as the listening HTTP channel implemented in Windows Communication Foundation, cannot be run as normal user by default, unless Windows communication Foundation IIS as the host. This is because the Windows communication Foundation HTTP channel uses HTTP. The SYS driver installs its listeners, and HTTP. SYS does not allow non-administrators to register listeners without the explicit authorization of the administrator.
To illustrate this issue, I built a simple Web service that contains the following two files: The source file for the service and the application configuration file. Figure 1 shows the code for the service. When you start the service as an administrator, everything is OK. However, when running the service as a normal user, there is a big problem! Figure 2 shows an exception that occurs when using the Microsoft®.net Framework 3.0 beta version 2.
Figure 2 Exception when Run as Normal User
system.servicemodel.diagnostics.callbackexception:a User callback threw an exception.
Check the exception stack and inner exception to determine the callback that failed.
---> System.NullReferenceException:Object reference not set to a instance of an Object.
At System.ServiceModel.Channels.DatagramChannelDemuxer ' 2. Onlistenerclosed (Object source, EventArgs args) at System.ServiceModel.Channels.CommunicationObject.OnClosed ()---En D of inner exception stack trace---at System.ServiceModel.Channels.CommunicationObject.OnClosed () at System.servicem Odel. Channels.CommunicationObject.Abort () at the System.ServiceModel.Channels.ChannelListenerBase.OnAbort () at System.ServiceModel.Channels.SecurityChannelListener ' 1.OnAbort () at System.ServiceModel.Channels.CommunicationObject.Abort () at System.ServiceModel.Channels.ChannelListenerBase.OnAbort () at System.ServiceModel.Channels.CommunicationObject.Abort () at System.ServiceModel.Dispatcher.ChannelDispatcheR.onabort () at the System.ServiceModel.Channels.CommunicationObject.Abort () at System.ServiceModel.ServiceHostBase.OnAbort () at the System.ServiceModel.Channels.CommunicationObject.Abort () at System.ServiceModel.Channels.CommunicationObject.Close (TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Close () at System.ServiceModel.Channels.CommunicationObject.Dispose () at Program.main (string[] args) in C:\work\HelloService\ Program.cs:line