Re: Problem with self hosting under the NetworkService account



I see this problem on XP as well. On Vista I run as an Administrator, on XP
as well during the install of the service.

Also, I am not getting an AddressAccessDeniedException, I am getting an
NullReferenceException.

Any other ideas?

Thanks, Dave


""Steven Cheng"" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:R8AgTjvPJHA.312@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Dave,

From your description, your windows service hosted WCF service report
exception at startup time, correct?

According to the error message and code snippet you provided, I think the
code and configuration should be ok. And since changing account will make
the result different, the problem is likely to be a permission specific
issue.

So far, based on my experience, there is a potential issue(which might be
caused by unsufficient permission) when initilaize the WCF host. That's
the
registring of the http listening url on vista machine. Based on the
computer name and wcf configuration, I think your dev box is a vista box
and you're using http channel, therefore, I think it is likely the cause.

Here is a web article which mentioned detailed information on registering
http url on vista machine(for a certain user account). You can try
granting
the http url (You want to use for your WCF endpoint) access permission to
the service account:

#AddressAccessDeniedException: HTTP could not register URL
http://+:8080/<¡­>.
http://blogs.msdn.com/paulwh/archive/2007/05/04/addressaccessdeniedexception
-http-could-not-register-url-http-8080.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my
manager
at: msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from

the community or a Microsoft Support Engineer within 2 business day is
acceptable. Please note that

each follow up response may take approximately 2 business days as the
support professional working

with you may need further investigation to reach the most efficient
resolution. The offering is not

appropriate for situations that require urgent, real-time or phone-based
interactions. Issues of this

nature are best handled working with a dedicated Microsoft Support
Engineer
by contacting Microsoft

Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.








--------------------
From: "Dave Burns" <dburns@xxxxxxxxxxxxxxxx>
Subject: Problem with self hosting under the NetworkService account
Date: Tue, 4 Nov 2008 12:53:41 -0600

I am self hosting a Web Service in a Windows service. I am trying to start
the service using the NT AUTHORITY\NetworkService account.

I get a NullReferenceException on ServiceHost.Open() in the
ServiceBase.OnStart() method. SCM throws a 1067 error as well.

I get the same problem with NT AUTHORITY\LocalService.

When I use the LocalSystem account, my domain account, or another regular
user account, the windows service starts just fine.

I would appreciate any help on this topic, thanks in advance!

Dave


Here's the code snippet:

class HostService : ServiceBase
{
private EventLog log;
private ServiceHost testServiceHost;

public HostService()
{
CanPauseAndContinue = false;
ServiceName = "Test Web Service";

// create an EventLog instance and assign its source.
this.log = new EventLog();
this.log.Source = HostInstaller.SERVICE_EVENT_SOURCE;

EventLog.WriteEntry("Got through constructor",
EventLogEntryType.Information);
}

static void Main()
{
// load the service into memory.
ServiceBase.Run(new HostService());
}

// start the service.
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("At the top of OnStart",
EventLogEntryType.Information);

// request 60 seconds for startup from SCM, just in case
RequestAdditionalTime(60000);

EventLog.WriteEntry("After RequestAdditionalTime()",
EventLogEntryType.Information);

// start self hosting
ServiceEndpoint endpoint = null;
try
{
endpoint = this.testServiceHost.Description.Endpoints[0];
this.testServiceHost = new ServiceHost(typeof(RmTestService));
EventLog.WriteEntry("After new ServiceHost()",
EventLogEntryType.Information);

// blows up here!!!
this.testServiceHost.Open();
}
catch (Exception e)
{
EventLog.WriteEntry("Problem starting " +
endpoint.Contract.Name
+ ": " + e.Message, EventLogEntryType.Error);
throw e;
}
}

Here's app.config snippet:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="RmWebService.RmWebServiceBehavior"
name="Rimage.Web.Service.RmTestService">
<host>
<baseAddresses>
<add
baseAddress="http://vista-draskin:55555/RmTestService.svc"/>
</baseAddresses>
</host>
<endpoint address="http://vista-draskin:55555/RmTestService.svc";
binding="basicHttpBinding" name="SoapEndpoint"
bindingNamespace="http://www.rimage.com/RmTestService";
contract="Rimage.Web.Service.IRmTestService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="MexEndpoint"
bindingNamespace="http://www.rimage.com/RmTestService";
contract="IMetadataExchange" />
</service>

</services>

<behaviors>
<endpointBehaviors>
<behavior
name="Rimage.Web.Service.RmAjaxTestServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RmWebService.RmWebServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>





.



Relevant Pages

  • RE: proper way to insert program for run on startup in Vista
    ... Yes, on Vista, a normal process runs under Admin Approval mode if you used ... "Administrators" group or Local System account, ... Microsoft Online Community Support ...
    (microsoft.public.platformsdk.security)
  • Re: Vista and Fax Client on SBS 2003
    ... Could Vista be trying to logon to the domain with the built in system ... account on thw workstation which shouldn't work! ... see Help and Support Center at ...
    (microsoft.public.windows.server.sbs)
  • Re: Vista Ultimate SP1 Window Mail
    ... Hotmail and MSN Accounts POP3/SMTP Access ... If entry of a hotmail, live, or msn.com address yields the 'no longer supports the http' message..then ... Modify the email address and username field contents when setting up the account, setup the email account with all other correct settings, once setup, edit/correct the email address and username fields. ... Why won't Vista accept Microsoft's own e-miail and if it doesnt why is it ...
    (microsoft.public.windows.vista.mail)
  • Re: Product ID For Online Support
    ... >Not sure about support for the Home Use program since it ... >account will be deleted without reading. ... As I mentioned in my thread, OE and Outlook ...
    (microsoft.public.office.misc)
  • Re: Need to understand permissions and ownership
    ... I am the only user and have only one administrator account with my name. ... There are also some other folders such as: ... The vista help files are so fragmented and confusing that they are ...
    (microsoft.public.windows.vista.general)

Quantcast