|
44 | 44 | namespace CSExeCOMServer |
45 | 45 | { |
46 | 46 | [ComVisible(true)] |
47 | | - [Guid("DB9935C1-19C5-4ed2-ADD2-9A57E19F53A3")] |
48 | 47 | [ClassInterface(ClassInterfaceType.None)] // No ClassInterface |
| 48 | + [Guid("DB9935C1-19C5-4ed2-ADD2-9A57E19F53A3")] |
49 | 49 | [ComSourceInterfaces(typeof(ISimpleObjectEvents))] |
50 | | - public class SimpleObject : ReferenceCountedObject, ISimpleObject |
| 50 | + public class SimpleObject : ISimpleObject |
51 | 51 | { |
52 | | - // These routines perform the additional COM registration needed by |
53 | | - // the service. |
54 | | - |
55 | | - [ComRegisterFunction] |
56 | | - [EditorBrowsable(EditorBrowsableState.Never)] |
57 | | - public static void Register(Type t) |
| 52 | + public SimpleObject() |
58 | 53 | { |
59 | | - try |
60 | | - { |
61 | | - HelperMethods.RegasmRegisterLocalServer(t); |
62 | | - } |
63 | | - catch (Exception ex) |
64 | | - { |
65 | | - Console.WriteLine(ex.Message); // Log the error |
66 | | - throw ex; // Re-throw the exception |
67 | | - } |
| 54 | + // Increment the lock count of objects in the COM server. |
| 55 | + ExecutableComServer.Instance.Lock(); |
68 | 56 | } |
69 | 57 |
|
70 | | - [ComUnregisterFunction] |
71 | | - [EditorBrowsable(EditorBrowsableState.Never)] |
72 | | - public static void Unregister(Type t) |
| 58 | + ~SimpleObject() |
73 | 59 | { |
74 | | - try |
75 | | - { |
76 | | - HelperMethods.RegasmUnregisterLocalServer(t); |
77 | | - } |
78 | | - catch (Exception ex) |
79 | | - { |
80 | | - Console.WriteLine(ex.Message); // Log the error |
81 | | - throw ex; // Re-throw the exception |
82 | | - } |
| 60 | + // Decrement the lock count of objects in the COM server. |
| 61 | + ExecutableComServer.Instance.Unlock(); |
83 | 62 | } |
84 | 63 |
|
85 | 64 | private float fField = 0f; |
@@ -113,5 +92,38 @@ public void GetProcessThreadId(out int processId, out int threadId) |
113 | 92 | public delegate void FloatPropertyChangingEventHandler(float NewValue, ref bool Cancel); |
114 | 93 |
|
115 | 94 | public event FloatPropertyChangingEventHandler FloatPropertyChanging; |
| 95 | + |
| 96 | + // These routines perform the additional COM registration needed by |
| 97 | + // the service. |
| 98 | + |
| 99 | + [ComRegisterFunction] |
| 100 | + [EditorBrowsable(EditorBrowsableState.Never)] |
| 101 | + public static void Register(Type t) |
| 102 | + { |
| 103 | + try |
| 104 | + { |
| 105 | + HelperMethods.RegasmRegisterLocalServer(t); |
| 106 | + } |
| 107 | + catch (Exception ex) |
| 108 | + { |
| 109 | + Console.WriteLine(ex.Message); // Log the error |
| 110 | + throw ex; // Re-throw the exception |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + [ComUnregisterFunction] |
| 115 | + [EditorBrowsable(EditorBrowsableState.Never)] |
| 116 | + public static void Unregister(Type t) |
| 117 | + { |
| 118 | + try |
| 119 | + { |
| 120 | + HelperMethods.RegasmUnregisterLocalServer(t); |
| 121 | + } |
| 122 | + catch (Exception ex) |
| 123 | + { |
| 124 | + Console.WriteLine(ex.Message); // Log the error |
| 125 | + throw ex; // Re-throw the exception |
| 126 | + } |
| 127 | + } |
116 | 128 | } |
117 | 129 | } |
0 commit comments