Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using COM+ in ASP.NET

Using COM+ in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netcomsysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jan larsen
    wrote on last edited by
    #1

    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
    
    M 1 Reply Last reply
    0
    • J jan larsen

      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
      
      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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[^]

      J 1 Reply Last reply
      0
      • M minhpc_bk

        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[^]

        J Offline
        J Offline
        jan larsen
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups