Created
November 14, 2012 16:52
-
-
Save opello/4073274 to your computer and use it in GitHub Desktop.
"Recycle" an IIS Publishing Point (mostly from http://blogs.southworks.net/ejadib/2009/04/16/live-smooth-streaming-how-to-start-stop-shutdown-a-publishing-point-programmatically/) Note: Target .NET 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using Microsoft.Web.Administration; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main( string[] args ) | |
{ | |
ServerManager serverManager = new ServerManager(); | |
ApplicationPool applicationPool = null; | |
try | |
{ | |
applicationPool = serverManager.ApplicationPools["Smooth"]; | |
} | |
catch | |
{ | |
Console.WriteLine( "Unable to find Application Pool named \"Smooth\"" ); | |
Environment.Exit( 1 ); | |
} | |
WorkerProcess workerProcess = null; | |
try | |
{ | |
workerProcess = applicationPool.WorkerProcesses[0]; | |
} | |
catch | |
{ | |
Console.WriteLine( "Unable to find first Worker Process" ); | |
Environment.Exit( 1 ); | |
} | |
try | |
{ | |
PublishingPointUtils.Shutdown( workerProcess, "Smooth", "/", "mss.isml" ); | |
} | |
catch( Exception e ) | |
{ | |
Console.WriteLine( e.Message ); | |
throw; | |
} | |
try | |
{ | |
PublishingPointUtils.Start( workerProcess, "Smooth", "/", "mss.isml" ); | |
} | |
catch( Exception e ) | |
{ | |
Console.WriteLine( e.Message ); | |
throw; | |
} | |
Console.WriteLine( "Done" ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using Microsoft.Web.Administration; | |
using System.Globalization; | |
namespace ConsoleApplication1 | |
{ | |
public static class PublishingPointUtils | |
{ | |
private static void ExecuteRscaFunction( ConfigurationElement workerProcess, | |
string siteName, | |
string applicationPath, | |
string fileName, | |
string functionName ) | |
{ | |
ConfigurationMethod configurationMethod = workerProcess.Methods["GetCustomData"]; | |
ConfigurationMethodInstance instance = configurationMethod.CreateInstance(); | |
instance.Input["guidIdOfFunctionCall"] = "Media_LiveStreaming_Control"; | |
string currentLogicalPath = applicationPath; | |
if( !currentLogicalPath.EndsWith( "/", StringComparison.OrdinalIgnoreCase ) ) | |
{ | |
currentLogicalPath = currentLogicalPath + "/"; | |
} | |
string fullPath = string.Concat( currentLogicalPath, fileName ); | |
string parameters = string.Format( CultureInfo.InvariantCulture, "{0};{1};{2}", | |
functionName, siteName, fullPath ); | |
instance.Input["parametersOfFunctionCall"] = parameters; | |
instance.Execute(); | |
} | |
public static void Start( ConfigurationElement workerProcess, | |
string siteName, | |
string applicationPath, | |
string fileName ) | |
{ | |
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "StartPublishingPoint" ); | |
} | |
public static void Stop( ConfigurationElement workerProcess, | |
string siteName, | |
string applicationPath, | |
string fileName ) | |
{ | |
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "StopPublishingPoint" ); | |
} | |
public static void Shutdown( ConfigurationElement workerProcess, | |
string siteName, | |
string applicationPath, | |
string fileName ) | |
{ | |
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "ShutdownPublishingPoint" ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This found a user apparently!
http://stackoverflow.com/questions/20457196/access-denied-error-when-attempting-to-reference-iis-worker-process-related-to