Using COM+ in ASP.NET
-
I'm having troubles using a COM+ application thorugh ASP.NET. The main problem is: I want to use the ICOMAdminCatalog interface to kill a COM+ service that has entered an invalid state which it can't recover from. Apparently, I can't change the security settings for the comadmin application, so, advised by minhpc_bk, I made a ServicedComponent that runs as a COM+ application. This component I can control completely, and its sole purpose is to invoke the ShutdownApplication method in the ICOMAdminCatalog interface. The component works perfectly when started by a console application, but I can't make it work in an ASP.NET application. I made two exported methods in my component: KillComConnector and DoSomethingHarmless. The first method shuts down a COM+ server component, and the second simply returns the integer 42. When I invoke, in ASP.NET, KillComConnector I get the following error:
ShutDownComConnector(): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: QueryInterface for interface ComConKiller.IComConKiller failed. Server stack trace: at ComConKiller.IComConKiller.KillComConnector(String comConnectorApplicationName) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at ComConKiller.ComConKiller.KillComConnector(String comConnectorApplicationName) --- End of inner exception stack trace --- at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, Bi
-
I'm having troubles using a COM+ application thorugh ASP.NET. The main problem is: I want to use the ICOMAdminCatalog interface to kill a COM+ service that has entered an invalid state which it can't recover from. Apparently, I can't change the security settings for the comadmin application, so, advised by minhpc_bk, I made a ServicedComponent that runs as a COM+ application. This component I can control completely, and its sole purpose is to invoke the ShutdownApplication method in the ICOMAdminCatalog interface. The component works perfectly when started by a console application, but I can't make it work in an ASP.NET application. I made two exported methods in my component: KillComConnector and DoSomethingHarmless. The first method shuts down a COM+ server component, and the second simply returns the integer 42. When I invoke, in ASP.NET, KillComConnector I get the following error:
ShutDownComConnector(): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: QueryInterface for interface ComConKiller.IComConKiller failed. Server stack trace: at ComConKiller.IComConKiller.KillComConnector(String comConnectorApplicationName) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at ComConKiller.ComConKiller.KillComConnector(String comConnectorApplicationName) --- End of inner exception stack trace --- at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, Bi
Hi Jan, It sounds like a security issue. In this case, you can try to set impersonation in the Web.config file with
<identity>
element:<identity impersonate="true" userName="uid" password="pwd"/>
For more information, you can look at this <identity> Element[^]
-
Hi Jan, It sounds like a security issue. In this case, you can try to set impersonation in the Web.config file with
<identity>
element:<identity impersonate="true" userName="uid" password="pwd"/>
For more information, you can look at this <identity> Element[^]
Yeah, I know, but this app is to be cleared by the security department in a large financial institution, so impersonation really isn't an option. My first error was to use impersonation as a convenience before testing if I could actually run the component in a real life situation. It seems that it may not be worth the effort, I think I settle for writing the go-between component in plain ATL/C++, but I sure would like to know if the security issue could be solved, or if it is a bug in the cominterop framework. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus