473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with ServiceHost.Open and NT AUTHORITY\NetworkService

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 Raskin
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.RmWebServiceBe havior"
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.RmAjaxTestServiceAspNetAj axBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RmWebService.RmWebServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

Oct 31 '08 #1
0 1936

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Robert McGregor | last post by:
Hi all, I've got a Front End / Back End database that was working just fine. One day i opened the FE to find that if I tried to open one of the linked tables from the database window, nothing...
7
by: Mike | last post by:
Hi! I posted this question in browser_ctl group as well but got no results. I have a form with embedded WebBrowser. Upon clicking on a link in the embedded webbrowser that calls JavaScript's...
2
by: Steve Chatham | last post by:
I use the following code: Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged Dim sFile As String =...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
10
by: Chris Bordeman | last post by:
Hi all. I created a custom ServiceHost object and did a bunch of initialization there. Now I need to access an object in it from the actual WCF service class. How can this be done? Thanks!!!
1
by: blutner | last post by:
Hello, I have got a little test application, which provides an WCF service and wants to consume it as well. The access does only succeed for the case, that the consumption is done by another...
4
by: Dave Burns | last post by:
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.