We have a case to deploy Cassini (both Explorer and ASP .NET 2.0 Web Server) with out application and register the application, all done during installation of our application. While we use InstallShield to install our application, we trigger Cassini Explorer and Web Server MSI through our InstallScript.
Adding to this, our Installer class registers our application with Cassini, using .Net reflection. Reflection is employed here, as we cannot reference to CassiniConfiguration assembly both at Compile time and runtime of our Installation.
So the code piece as below.
Assembly cassiniConfigurationAssembly = Assembly.LoadFrom(CASSINI_CONFIGURATION_ASSEMBLY_PATH);
Type metabaseType = cassiniConfigurationAssembly.GetType("CassiniConfiguration.Metabase");
if (metabaseType != null)
{
MethodInfo registerApplicationMethod =
metabaseType.GetMethod("RegisterApplication",
new Type[] { typeof(Guid),
typeof(string),
typeof(string),
typeof(string),
typeof(string),
typeof(bool)});
registerApplicationMethod.Invoke(metabaseType,
new Object[] { new Guid(APPLICATION_GUID),
"Name",
"Description",
"Path",
"Default Document",
true });
}
Considering that we pass proper values to all parameters, our application gets registered to Cassini (i.e. no exception);
We have two different observation here, which are not very consistent but can well be reproduced with little effort.
Observation One - Launch Cassini Explorer, it fails to launch. Perform restart of Cassini Windows Service and re-try to launch Cassini Explorer, it launches and displays our application as a Registered application.
Observation Two - Launch Cassini Explorer, it launches and displays our application as Registered application. Click on the application hyperlink in Cassini Explorer, the application fails to launch. Perform restart of Cassini Windows Service and re-try the operation (click on application hyperlink). Our application launches successfully.
We are very confused with this behavior. See if you can help us.