By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Creating Windows Services programatically - help

P: n/a
Hi,

I'm trying to create a Windows service programmatically that will do the
following:

- When a user logs on, it will automatically run a service that uses BITS
(Background Intelligent Transfer Service) to check for the most current
version of a file and downloads this version.

I have a wrapper class thats imported as a reference in order for me to be
able to use BITS.

I am able to run and install the service into the SCM but when I attempt to
start the service I get the following message:

"The test service on Local Computer started and then stopped. Some services
stop automatically if they have no work to do, for example, the Performance
Logs and Alerts service."

I then see the following message logged in the Application Event viewer:

"
Service cannot be started. System.IO.FileNotFoundException: File or assembly
name Microsoft.Msdn.Samples.BITS, or one of its dependencies, was not found.

File name: "Microsoft.Msdn.Samples.BITS"

at testBits.startBits.OnStart(String[] args)

at System.ServiceProcess.ServiceBase.ServiceQueuedMai nCallback(Object state)

=== Pre-bind state information ===

LOG: DisplayName = Microsoft.Msdn.Samples.BITS, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=null

(Fully-specified)

LOG: Appbase = C:\bits\testBits\obj\Debug\

LOG: Initial PrivatePath = NULL

Calling assembly : testBits, Version=1.0.2090.30051, Culture=neutral,
PublicKeyToken=null.

===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).

LOG: Post-policy reference: Microsoft.Msdn.Samples.BITS, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=null

LOG: Attempting download of new URL
file:///C:/bits/testBits/obj/Debug/Microsoft.Msdn.Samples.BITS.DLL.

LOG: Attempting download of new URL
file:///C:/bits/testBits/obj/Debug/Microsoft.Msdn.Samples.BITS/Microsoft.Msdn.Samples.BITS.DLL.

LOG: Attempting download of new URL
file:///C:/bits/testBits/obj/Debug/Microsoft.Msdn.Samples.BITS.EXE.

LOG: Attempting download of new URL
file:///C:/bits/testBits/obj/Debug/Microsoft.Msdn.Samples.BITS/Microsoft.Msdn.Samples.BITS.EXE.

"

Could someone please tell me where i'm going wrong and/or what I need to
change.

Thanks.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Amongin Ewinyu wrote:
I have a wrapper class thats imported as a reference in order for me to be
able to use BITS.

Have you tested the wrapper in a regular Windows Forms app to make sure
it works properly?
Service cannot be started. System.IO.FileNotFoundException: File or assembly
name Microsoft.Msdn.Samples.BITS, or one of its dependencies, was not found.

File name: "Microsoft.Msdn.Samples.BITS"


Is the wrapper file installed in the correct location? And are any
files it depends on also installed correctly?

Nov 21 '05 #2

P: n/a
Yes I have tested the wrapper in a regular Windows form app. and it works
perfectly, the problem occurs when I try and use the same code in the
OnStart method of the Service class.

The wrapper depends on on two other files and they are all stored/installed
in the same location, which is the directory of the project.
- Is this the correct location?
- Is there a particular place that I need to install the wrapper file and
its dependencies for it to work?

Also I have noticed that the wrapper class and its dependencies do not have
any public key tokens, could this be causing the error?

Thanks, Amongin

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Amongin Ewinyu wrote:
I have a wrapper class thats imported as a reference in order for me to
be
able to use BITS.


Have you tested the wrapper in a regular Windows Forms app to make sure
it works properly?
Service cannot be started. System.IO.FileNotFoundException: File or
assembly
name Microsoft.Msdn.Samples.BITS, or one of its dependencies, was not
found.

File name: "Microsoft.Msdn.Samples.BITS"


Is the wrapper file installed in the correct location? And are any
files it depends on also installed correctly?

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.