Author: joergr
Date: 2005-04-09 16:34:07 -0400 (Sat, 09 Apr 2005)
New Revision: 42745
Modified:
trunk/mcs/tools/mono-service/ChangeLog
trunk/mcs/tools/mono-service/mono-service.cs
Log:
2005-04-09 Joerg Rosenkranz <[EMAIL PROTECTED]>
* mono-service.cs: Fixed dynamic loading of assemblies
from services. Cleaned up callback code.
Modified: trunk/mcs/tools/mono-service/ChangeLog
===================================================================
--- trunk/mcs/tools/mono-service/ChangeLog 2005-04-09 20:33:31 UTC (rev
42744)
+++ trunk/mcs/tools/mono-service/ChangeLog 2005-04-09 20:34:07 UTC (rev
42745)
@@ -1,3 +1,8 @@
+2005-04-09 Joerg Rosenkranz <[EMAIL PROTECTED]>
+
+ * mono-service.cs: Fixed dynamic loading of assemblies
+ from services. Cleaned up callback code.
+
2005-04-08 Joerg Rosenkranz <[EMAIL PROTECTED]>
* mono-service.cs: Restructured code to run service main loop
Modified: trunk/mcs/tools/mono-service/mono-service.cs
===================================================================
--- trunk/mcs/tools/mono-service/mono-service.cs 2005-04-09 20:33:31 UTC
(rev 42744)
+++ trunk/mcs/tools/mono-service/mono-service.cs 2005-04-09 20:34:07 UTC
(rev 42745)
@@ -97,6 +97,9 @@
return 1;
}
}
+
+ // Allow loading of dynamic assemblies
+ AppDomain.CurrentDomain.AppendPrivatePath
(Environment.CurrentDirectory);
// Use lockfile to allow only one instance
if (lockfile == null)
@@ -155,12 +158,19 @@
}
// Hook up RunService callback
+ Type cbType = Type.GetType
("System.ServiceProcess.ServiceBase+RunServiceCallback, System.ServiceProcess");
+ if (cbType == null){
+ error ("Internal Mono Error: Could not find
RunServiceCallback in ServiceBase");
+ return 1;
+ }
+
FieldInfo fi = typeof (ServiceBase).GetField ("RunService",
BindingFlags.Static | BindingFlags.NonPublic);
if (fi == null){
error ("Internal Mono Error: Could not find RunService
in ServiceBase");
return 1;
}
- fi.SetValue (null, new EventHandler (RunService));
+ fi.SetValue (null, Delegate.CreateDelegate(cbType,
+ typeof (MonoServiceRunner).GetMethod ("RunService",
BindingFlags.Static | BindingFlags.NonPublic)));
// And run its Main. Our RunService handler is invoked from
// ServiceBase.Run.
@@ -177,15 +187,8 @@
}
// The main service loop
- private static void RunService (object o, EventArgs e)
+ private static void RunService (ServiceBase [] services)
{
- FieldInfo fi = typeof (ServiceBase).GetField
("RegisteredServices", BindingFlags.Static | BindingFlags.NonPublic);
- if (fi == null){
- error ("Internal Mono Error: Could not find
RegisteredServices in ServiceBase");
- return;
- }
-
- ServiceBase [] services = (ServiceBase []) fi.GetValue (null);
if (services == null || services.Length == 0){
error ("No services were registered by this service");
return;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches