internal bool CreateApplication ()
{
SetCurrentApplication (null);
if (EntryAssembly == null) {
EmitError (2103, "Could not find the entry point assembly") ;
return false;
}
Type entry_type = EntryAssembly.GetType (EntryPointType);
if (entry_type == null) {
EmitError (2103, String.Format ("Could not find the startup type {0} on the {1}",
EntryPointType, EntryPointAssembly));
return false;
}
if (!entry_type.IsSubclassOf (typeof (Application)) && entry_type != typeof (Application)) {
#if SANITY
Type t = entry_type;
int spacing = 0;
while (t != null) {
if (spacing > 0) {
for (int i = 0; i < spacing; i ++)
Console.Write (" ");
Console.Write ("+ ");
}
Console.WriteLine ("{0}", t);
spacing += 2;
t = t.BaseType;
}
#endif
EmitError (2103, "Startup type does not derive from System.Windows.Application");
return false;
}
foreach (Assembly a in Assemblies)
Application.LoadXmlnsDefinitionMappings (a);
Application instance = null;
try {
instance = (Application) Activator.CreateInstance (entry_type);
} catch {
EmitError (2103, String.Format ("Error while creating the instance of type {0}", entry_type));
return false;
}
SetCurrentApplication (instance);
StartupEventArgs args = new StartupEventArgs();
instance.OnStartup (args);
return true;
}