locked
WHS 2011 SDK problems with StorageManager.Connect() RRS feed

  • Question

  • Hello,

    I am developing a windows service to manage the HDD lights on my HP EX485 since there are no drivers for this functionality under WHS 2011. I am using the latest "Windows Server Solutions SDK" to do my development.

    To do this I am using the Microsoft.WindowsServerSolutions.Storage.StorageManager class (http://msdn.microsoft.com/en-us/library/microsoft.windowsserversolutions.storage.storagemanager.aspx). I am having issues to connect to the StorageManager with the Connect() method. Here are the different scenarios:

    1) Windows WPF application: when calling the synchronous Connect() method the application hangs for about a minute and then I get an exception (details below).
    2) Windows WPF application: when calling the asynchronous ConnectAsync() method it works.
    3) Windows WPF application: when calling the synchronous Connect() method by queuing it in another thread it works (ThreadPool.QueueUserWorkItem()).
    4) Windows service: when calling the synchronous Connect() method the application hangs for about a minute and then I get an exception (details below).
    5) Windows service: when calling the asynchronous ConnectAsync() method the method call goes through but I never get connected.
    6) Windows service: when calling the synchronous Connect() method by queuing it in another thread I also get an exception.

    Since my goal is to write a Windows Service I do not have a working solution. Here is the useless exception I am getting:

    Exception of type 'Microsoft.WindowsServerSolutions.Storage.StorageObjectModelException' was thrown. (ErrorCode 0x800401f6)

    But looking down the Intellitrace exceptions history, I get a more useful exception:

    A System.ServiceModel.EndpointNotFoundException was thrown: "There was no endpoint listening at net.tcp://server:65532//Microsoft.Windows.ServcerSolutions.Common.ProviderFramework.IProviderRegistry that could accept the message...

    But that doesn't explain why it only works in a Windows application with the ConnectAsync() or Connect() queued in another thread. My only guess is that it needs the message pump which would mean that I cannot write a Windows service. But I really don't understand why this class would have been written to be dependent on a message pump making it useless in a Windows Service.

    I hope someone can help me here.

    Thanks in advance for any help.

    Louis



    Sunday, April 17, 2011 10:13 PM

Answers

  • Hello Martin,

    Thank you for your reply.

    Your reply gave me hope and told me something must be wrong in my project. So I created a windows server project from scratch and just connected to the StorageManager, that worked. Little by little I put back all the code from my previous project. And go figure, it works! There's something broken in my first project but for now I don't know what. I put the same code in the new service, so the problem is not the code. What's important is that everything works!

    If I find out what's wrong I will post it here since somebody could fall in the same trap as me.

    Thank you for your psychological support ;)

    Regards,

    Louis


    Wednesday, April 20, 2011 12:52 PM

All replies

  • I've used that in a service, so it should work.

    Do you initialize your environment in your service? See http://msdn.microsoft.com/en-us/library/gg513958.aspx

    Microsoft.WindowsServerSolutions.Common.WindowsServerSolutionsEnvironment.Initialize();
    

     Are you developing on your server?


    LightsOut - Power Management for Windows Home Server http://www.home-server-blog.de/add-ins/lightsout/#en
    Wednesday, April 20, 2011 10:47 AM
    Moderator
  • Hello Martin,

    Thank you for your reply.

    Your reply gave me hope and told me something must be wrong in my project. So I created a windows server project from scratch and just connected to the StorageManager, that worked. Little by little I put back all the code from my previous project. And go figure, it works! There's something broken in my first project but for now I don't know what. I put the same code in the new service, so the problem is not the code. What's important is that everything works!

    If I find out what's wrong I will post it here since somebody could fall in the same trap as me.

    Thank you for your psychological support ;)

    Regards,

    Louis


    Wednesday, April 20, 2011 12:52 PM
  • Good to know it's working now.
    LightsOut - Power Management for Windows Home Server http://www.home-server-blog.de/add-ins/lightsout/#en
    Wednesday, April 20, 2011 2:09 PM
    Moderator