Application.Run() In a Windows Service

G

Guest

I have a multi threaded windows form application that runs great after
calling Application.Run(). Application.Run is required for a COM component
I a using in the app (required for message loop). I have created a windows
service from VStudio 2005 template. What is the windows service replacement
for Application.Run()?
 
D

Dubravko Sever

I have a multi threaded windows form application that runs great after
calling Application.Run(). Application.Run is required for a COM component
I a using in the app (required for message loop). I have created a windows
service from VStudio 2005 template. What is the windows service
replacement for Application.Run()?
ServiceBase.Run(new service_class); maybe,
but you have to write class (service_class) with OnStart (here you must
call your main code) , OnPause, OnStop methods that inherites
System.ServiceProcess.ServiceBase

D
 
G

Guest

Thanks a lot. I have tried, however, no luck. For some reason this com
component just wont function without application.run... which wont work in
the win service.
 
D

Dubravko Sever

Have you check your account does it have enough permissions? Try to run your
service as a administrator just for testing.

D
 
G

Guest

A Windows service can be started from the command line using Net Start
<yourServiceName> or Net Stop <yourServiceName>. The easiest is to use the
Services MMC.
 
W

Willy Denoyette [MVP]

I have a multi threaded windows form application that runs great after
calling Application.Run(). Application.Run is required for a COM component
I a using in the app (required for message loop). I have created a windows
service from VStudio 2005 template. What is the windows service
replacement for Application.Run()?


No, Application.Run is not required for COM (apartment style of objects),
all you need is to do is initialize the thread that creates your COM
component to enter the STA, that means you need to set the ApartmentState to
STA before starting the thread, that way you are sure the component runs on
the same thread as the caller and no marshaling is needed.
However, you need to make sure you aren't calling any blocking wait, only
pumping waits are pumping COM messages, this is required to let the
Finalizer thread (running in the MTA) to marshal calls into the STA thread
whenever your RCW needs to be released.

Willy.
 
G

Guest

Thanks. Everything within the service runs fine (I write text to a text
file for instance). Only problem is, without application.run, the com
component reference does not function.
 
G

Guest

Thank you. Threading is STA. Here is an excert of the code that works fine
as a windows form... But, for some reason I can not put it together to work
as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and allows
ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.

Jay
 
W

Willy Denoyette [MVP]

Thank you. Threading is STA. Here is an excert of the code that works
fine as a windows form... But, for some reason I can not put it together
to work as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and allows
ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.


It looks like you are using an ActiveX Component, now AX was in general not
designed to be used from a service, make them work is in general a pain in
the a**, the problem is with the callbacks that arrive on anything but the
callers thread, that is they end on the thread pool threads which are MTA
and as such they need to be marshaled to the STA thread, that means you
need to pump Windows messages (not COM message), but services are not
designed to pump a message queue, only Windows applications are, you see the
dilemma?

I would suggest you to try to run this from a Console application first,
it's much easier to debug, and look how far you get before you drop this
into a service.

Willy.
 
G

Guest

Thanks Willy. I will try the console approach, however, still need to solve
the windows service dilema. For whatever reason the app runs perfectly as a
windows form but not as a windows service. And, when I remove
application.run from the windows form the app no longer runs. Any idea if
there is anything else I can try to get this functioning as a service?
Thank you very much. I really appreciate your help.



Willy Denoyette said:
Thank you. Threading is STA. Here is an excert of the code that works
fine as a windows form... But, for some reason I can not put it together
to work as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and allows
ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.


It looks like you are using an ActiveX Component, now AX was in general
not designed to be used from a service, make them work is in general a
pain in the a**, the problem is with the callbacks that arrive on anything
but the callers thread, that is they end on the thread pool threads which
are MTA and as such they need to be marshaled to the STA thread, that
means you need to pump Windows messages (not COM message), but services
are not designed to pump a message queue, only Windows applications are,
you see the dilemma?

I would suggest you to try to run this from a Console application first,
it's much easier to debug, and look how far you get before you drop this
into a service.

Willy.
 
B

Brian Schwartz

What does the COM component do? Was it written in-house or is it an outside
product?

If in-house, obviously I'm going to ask if you can rewrite it in .NET. But
since that's probably not the case...what if you wrap the COM component in a
..NET console app, and call the .NET console app from your windows service?
I've never tried it...just an idea off the top of my head.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets


Thanks Willy. I will try the console approach, however, still need to
solve the windows service dilema. For whatever reason the app runs
perfectly as a windows form but not as a windows service. And, when I
remove application.run from the windows form the app no longer runs. Any
idea if there is anything else I can try to get this functioning as a
service? Thank you very much. I really appreciate your help.



Willy Denoyette said:
Thank you. Threading is STA. Here is an excert of the code that works
fine as a windows form... But, for some reason I can not put it
together to work as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and allows
ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.


It looks like you are using an ActiveX Component, now AX was in general
not designed to be used from a service, make them work is in general a
pain in the a**, the problem is with the callbacks that arrive on
anything but the callers thread, that is they end on the thread pool
threads which are MTA and as such they need to be marshaled to the STA
thread, that means you need to pump Windows messages (not COM message),
but services are not designed to pump a message queue, only Windows
applications are, you see the dilemma?

I would suggest you to try to run this from a Console application first,
it's much easier to debug, and look how far you get before you drop this
into a service.

Willy.
 
G

Guest

Thanks a lot. It is a third party app that should be a .net component... I
make reference to it as a .net component in the .net tab in references.

Brian Schwartz said:
What does the COM component do? Was it written in-house or is it an
outside product?

If in-house, obviously I'm going to ask if you can rewrite it in .NET. But
since that's probably not the case...what if you wrap the COM component in
a .NET console app, and call the .NET console app from your windows
service? I've never tried it...just an idea off the top of my head.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets


Thanks Willy. I will try the console approach, however, still need to
solve the windows service dilema. For whatever reason the app runs
perfectly as a windows form but not as a windows service. And, when I
remove application.run from the windows form the app no longer runs. Any
idea if there is anything else I can try to get this functioning as a
service? Thank you very much. I really appreciate your help.



Willy Denoyette said:
<msnews.microsoft.com> wrote in message
Thank you. Threading is STA. Here is an excert of the code that works
fine as a windows form... But, for some reason I can not put it
together to work as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and
allows ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.



It looks like you are using an ActiveX Component, now AX was in general
not designed to be used from a service, make them work is in general a
pain in the a**, the problem is with the callbacks that arrive on
anything but the callers thread, that is they end on the thread pool
threads which are MTA and as such they need to be marshaled to the STA
thread, that means you need to pump Windows messages (not COM message),
but services are not designed to pump a message queue, only Windows
applications are, you see the dilemma?

I would suggest you to try to run this from a Console application first,
it's much easier to debug, and look how far you get before you drop this
into a service.

Willy.
 
G

Guest

It's got to be something with the way I'm threading because as soon as I
remove threading and only instantiate one adx object everything works fine.
Aby thoughts?


Thanks a lot. It is a third party app that should be a .net component...
I make reference to it as a .net component in the .net tab in references.

Brian Schwartz said:
What does the COM component do? Was it written in-house or is it an
outside product?

If in-house, obviously I'm going to ask if you can rewrite it in .NET.
But since that's probably not the case...what if you wrap the COM
component in a .NET console app, and call the .NET console app from your
windows service? I've never tried it...just an idea off the top of my
head.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets


Thanks Willy. I will try the console approach, however, still need to
solve the windows service dilema. For whatever reason the app runs
perfectly as a windows form but not as a windows service. And, when I
remove application.run from the windows form the app no longer runs.
Any idea if there is anything else I can try to get this functioning as
a service? Thank you very much. I really appreciate your help.



<msnews.microsoft.com> wrote in message
Thank you. Threading is STA. Here is an excert of the code that
works fine as a windows form... But, for some reason I can not put it
together to work as a service.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Runtime.InteropServices;
using Envox.ADXVoice;
using System.Data.SqlClient;
using System.Configuration;

namespace AnsweringSystem
{
public partial class Form1 : Form
{
private LineHandler[] LineArray;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int iFromChannel = 0;
int iToChannel = 3; //4 channels

LineArray = new LineHandler[iToChannel - iFromChannel + 1];

for (int iChannel = iFromChannel; iChannel <= iToChannel;
iChannel++)
{
LineHandler Line = new LineHandler();
LineArray[iChannel - iFromChannel] = Line;
Line.iChannel = iChannel;
ThreadStart ts = new ThreadStart(Line.ProcessingThread);
Thread wrkThread = new Thread(ts);
Line.CurrentThread = wrkThread;
wrkThread.SetApartmentState(ApartmentState.STA);
wrkThread.Name = iChannel.ToString();
wrkThread.Start();
}
}

//Main class to handle individual channels on separate threads
private class LineHandler
{
public int iChannel = -1;
public Thread CurrentThread = null;

private ADXVoiceClass ADXVoice1 = null;

private delegate void TraceThreadSafe(string msg);

public void ProcessingThread()
{
try
{
ADXVoice1 = new ADXVoiceClass();
ADXVoice1.TrunkAssign(iChannel);
ADXVoice1.IncomingCall += new
_IADXVoiceEvents_IncomingCallEventHandler(OnIncomingCall);
}
catch (COMException e)
{
ADXVoice1 = null;
return;
}
catch (Exception e)
{
ADXVoice1 = null;
return;
}

//Start message loop (keeps thread from exiting and
allows ADX to process events, including state changes)
Application.Run();

Marshal.ReleaseComObject(ADXVoice1); //make ADXVoice1
eligible for garbage collection
GC.Collect(); //force Garbage Collection
GC.WaitForPendingFinalizers(); //wait for completion
}

private void OnIncomingCall()
{
//code here to play prompts, branch to other methods, etc.
}

} //End LineHandler class

}
}


I very much appreciate any advice you may have. Thank you very much.



It looks like you are using an ActiveX Component, now AX was in general
not designed to be used from a service, make them work is in general a
pain in the a**, the problem is with the callbacks that arrive on
anything but the callers thread, that is they end on the thread pool
threads which are MTA and as such they need to be marshaled to the STA
thread, that means you need to pump Windows messages (not COM
message), but services are not designed to pump a message queue, only
Windows applications are, you see the dilemma?

I would suggest you to try to run this from a Console application
first, it's much easier to debug, and look how far you get before you
drop this into a service.

Willy.
 
W

Willy Denoyette [MVP]

Thanks Willy. I will try the console approach, however, still need to
solve the windows service dilema. For whatever reason the app runs
perfectly as a windows form but not as a windows service. And, when I
remove application.run from the windows form the app no longer runs. Any
idea if there is anything else I can try to get this functioning as a
service? Thank you very much. I really appreciate your help.

Well, it runs from a Windows.Forms application because this is the normal
habitat for AX controls, they run in an STA thread that pumps the windows
message queue. So, the only way to make it work (be it unreliable) is to
make your service a Windows application, that is, create a context with a
form and run the message pump by a call to Application.Run, but beware that
you need to handle a lot of interactions with the windows system (handle
Windows events like Close etc...), and you'll need to find a way to interact
with the COM object too. Note that such scenario is not supported, it's
really a bad idea to try to run AX in Windows Services, it will break sooner
than later ....

Willy.
 
W

Willy Denoyette [MVP]

Thanks a lot. It is a third party app that should be a .net component...
I make reference to it as a .net component in the .net tab in references.


Wait a minute, if you set a reference to a ".NET component", it means it's a
".NET component" and NOT a COM object, so you may forget all what's been
said about COM, STA's and message queues. So again, may I ask you what you
mean by "it doesn't work", and as I said in another reply, try first to make
it work from a simple Console Application.

Willy.
 
W

Willy Denoyette [MVP]

It's got to be something with the way I'm threading because as soon as I
remove threading and only instantiate one adx object everything works
fine. Aby thoughts?


What do you mean by "the way you are threading" and "remove threading"?
Are you sure the third party .NET class doesn't call into COM, that is, are
you sure it's not a simple COM wrapper.

Willy.
 
B

Ben Voigt

I have a multi threaded windows form application that runs great after
calling Application.Run(). Application.Run is required for a COM component
I a using in the app (required for message loop). I have created a windows
service from VStudio 2005 template. What is the windows service
replacement for Application.Run()?

Create a thread to host your objects (not the main service thread which must
be controlled by the SCM).

In this thread, spend most of your time in a classic
PeekMessage/DispatchMessage loop, so COM marshalling works as expected.
 
G

Guest

Watching the Output window I'm noticing that without Application.Run in my
windows form app that the message loop doesnt start so the threads exit and
the .net component cant process events. Same thing with the windows
service. All is well in the windows form app with application.run. How can
i simulate this same application.run functionality in a windows service? I
very much appreciate all of your help. Thank you.
 
W

Willy Denoyette [MVP]

Watching the Output window I'm noticing that without Application.Run in my
windows form app that the message loop doesnt start so the threads exit
and the .net component cant process events. Same thing with the windows
service. All is well in the windows form app with application.run. How
can i simulate this same application.run functionality in a windows
service? I very much appreciate all of your help. Thank you.


Again, are you talking about a COM object or are you talking about a .NET
component, I'm asking this because in another reply you said that you were
adding a reference to a ".NET component" , and I replied by saying that a
..NET components is not a COM component.
Anyway, if it's a .NET component , it looks like it depends on
Windows.Forms, and this is a big no no in Windows Services, the
documentation states that it's not a supported scenario. If however you
don't care about all these warnings, just go ahaed, make your service a UI
styale application, by adding a reference to Windows.Forms, create a Form as
you did your Windows appliaction and set the Windows Service property
"Interact with the Desktop" to true and set the Identity of the Service
account to SYSTEM. But I warned you, you will end in a world of pain.

Willy.
 
B

Ben Voigt

Willy Denoyette said:
Again, are you talking about a COM object or are you talking about a .NET
component, I'm asking this because in another reply you said that you were
adding a reference to a ".NET component" , and I replied by saying that a
.NET components is not a COM component.
Anyway, if it's a .NET component , it looks like it depends on
Windows.Forms, and this is a big no no in Windows Services, the
documentation states that it's not a supported scenario. If however you
don't care about all these warnings, just go ahaed, make your service a UI
styale application, by adding a reference to Windows.Forms, create a Form
as you did your Windows appliaction and set the Windows Service property
"Interact with the Desktop" to true and set the Identity of the Service

no, don't enable "Interact with Desktop". That isn't needed for processing
the message queue, and is a very bad idea, not to mention no longer allowed
in Vista.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top