/// <summary> /// Stop this service. /// </summary> protected override void OnStop() { ChannelServices.UnregisterChannel(channel); channel = null; mediaServer.Dispose(); mediaServer = null; }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { if (mediaServer != null) { this.OnStop(); } mediaServer = new MediaServerCore("Intel's Media Server (" + System.Windows.Forms.SystemInformation.ComputerName + ")"); System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary(); channelProperties.Add("port", 12329); HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider()); //channel = new TcpChannel(12329); ChannelServices.RegisterChannel(channel); RemotingConfiguration.ApplicationName = "IntelUPnPMediaServer"; RemotingConfiguration.RegisterWellKnownServiceType(typeof(UPnPMediaServer), "UPnPMediaServer.soap", WellKnownObjectMode.Singleton); }