TReKiE / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

Windows Service doesn't sign in #196

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

- Create a Windows Service
- Add installers
- Use the following code:

namespace MSNPSharpServiceTest
{
    public partial class MSNPSharpServiceTest : ServiceBase
    {
        private Messenger msnMessenger = new Messenger();

        public MSNPSharpServiceTest()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            msnMessenger.Credentials = new Credentials("msnaddress", "msnpassword", MsnProtocol.MSNP18);
            msnMessenger.Nameserver.SignedIn += new EventHandler<EventArgs>(Nameserver_SignedIn);
            msnMessenger.Connect();
        }

        void Nameserver_SignedIn(object sender, EventArgs e)
        {
            msnMessenger.Owner.Status = PresenceStatus.Online;
        }

        protected override void OnStop()
        {
            msnMessenger.Disconnect();
        }
    }
}

- Let the Service run under the Local Service account.

- Install the service with installutil

- Start the service

What is the expected output? What do you see instead?
The msnaccount coming online.

What version of the product are you using? (MSNPSharp, OS, Mono etc.)
3.1.2 Beta (but i guess it won't work also on earlier versions)

Is your code check out from SVN or download from our download site?
It's downloaded from the site

Please provide any additional information below:
The only thing i know is that it gets passed the 
contactService_BeforeRunAsyncMethod event 
After that i get no events back anymore.

Original issue reported on code.google.com by freakysm...@gmail.com on 14 Jun 2010 at 7:52

GoogleCodeExporter commented 9 years ago
Sevices dont have a messageloop, your also not going to get far running it 
under the Local Service account either with the security restrictions on these 
privileged accounts... msnp-sharp uses allot of invoke's and events and without 
that messageloop windows forms simply cannot communicate the event pulse or 
invoke message between threads...

You have three choices, you can create your own message loop and change all the 
events/invoke's to process messages within your own loop, use task scheduler to 
run the process or run the process as a hidden window so its like a background 
process. 

I dont think you'll get far trying to use msnp-sharp from a service without a 
near complete rewrite of the library so I recommend developing it as a process 
and using task scheduler to run it (with a different user context if required) 
since a messageloop is created there or as the current user using a hidden 
window.

dmex

Original comment by dmex04@gmail.com on 19 Jun 2010 at 5:20

GoogleCodeExporter commented 9 years ago
Hi,

Dmex has already get the point :)

Original comment by freezing...@gmail.com on 21 Jun 2010 at 2:20