ASP.NET and STA COM objects

前端 未结 2 678
谎友^
谎友^ 2021-01-23 12:57

Looking to settle an argument here.

All the stuff I\'ve read on using a COM object created in VB from an ASP.NET page is surrounding with

WARNING - MAKE

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 13:32

    If you can modify the source of the COM object, you may be able to determine if its behaving as an STA through a simple experiment assuming you have a test environment.

    1. Call sleep for some significant amount of time in the component, say 30 seconds and deploy the component.

    2. Fire up a couple of browsers and hit the page requiring the component from two browsers at about the same time.

    3. Assuming the page has no other significant non-deterministic delays, you should be able to tell if this is a MTA or STA. If both pages return at the same time ( after about 30 seconds ), the component is running as an MTA. If one returns in 30 and the other in 60, its running as an STA.

    I would think that there is a way to inspect the registry or the dll itself as well, but it has been a little while since I was working in a mixed COM / ASP.NET world.

    Good luck!

提交回复
热议问题