3

I'm trying to create an windows service application which i would be able to add modules in it as we do in WPF and Silverlight. This is how i went throw :

public static class Program
{
    public static string CurrentAppPath { get; set; }

    static void Main()
    {
        Program.CurrentAppPath = Path.GetDirectoryName(
             System.Reflection.Assembly.GetEntryAssembly().Location);

        ShellBootstrapper bootstrapper = new ShellBootstrapper();
        bootstrapper.Run();
    }    
}

And for the ShellBootstrapper class :

class ShellBootstrapper : UnityBootstrapper
{
    protected override IModuleCatalog CreateModuleCatalog()
    {
        DirectoryModuleCatalog directoryCatalog = 
          new DirectoryModuleCatalog() { ModulePath = Program.CurrentAppPath };
        return directoryCatalog;
    }

    protected override System.Windows.DependencyObject CreateShell()
    {
        return null;
    }        

    public override void Run(bool runWithDefaultConfiguration)
    {
        base.Run(runWithDefaultConfiguration);

        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] 
        { 
            new MyService(logger)
        };
        ServiceBase.Run(ServicesToRun);
    }        
}

Are there any sample out there?

Ehsan Zargar Ershadi
  • 24,115
  • 17
  • 65
  • 95
  • These snippets seem to be okay. What are you missing? The only thing I'd change would be to remove the `new MyService` and let prism resolve that - use the `Container` property and `Resolve` to get your service with all dependencies. – Benjamin Podszun May 15 '11 at 12:32
  • Were you able to get your service to run? I have yet been unsuccessful, and I'm using EventAggregator and Unity in my Service. – grefly Aug 05 '11 at 07:39

1 Answers1

1

lock at this. you can download there sample as you can see in picture

After download and installing prism(v4), in root directory you have folder named as stock trader. that's what you need! (run desktop version). In section Modules you can Find folder named service.

This is simple, you can call Wcf-service in these method right here.(also you can use wcf method as async-service )

Rev
  • 2,269
  • 8
  • 45
  • 75