Using DSO and Multithreading in ASP.NET

If you are trying to use Decision Support Objects (DSO) to administer Analysis Services, then you should already know your code needs to run in the security context of someone in the OLAP Administrat

ITPro Today

April 20, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

If you are trying to use Decision Support Objects (DSO) to administer Analysis Services, then you should already know your code needs to run in the security context of someone in the OLAP Administrators group. In an ASP.NET application you might enable impersonation. Then when an OLAP Administrator logs into the web site, the ASP.NET page will execute using the client credentials. However, there is still a problem.

In the registry, look at the ThreadingModel key for any DSO component and youll see DSO has to run in a single threaded apartment (STA). ASP.NET pages run free threaded by default. This forces COM to activate a DSO component on a different thread, a thread that does not have the security credentials of the client. Thus, even with impersonation you are still not able to access the OLAP server via DSO.


Solution

In the @ Page directive of your aspx file set aspcompat=true. The aspcompat attribute forces the page to execute on an STA thread. When the DSO component is instantiated, COM allows the method calls to happen from the same thread executing the ASPX file, the thread with the clients security credentials.

Remember also when using the aspcompat attribute to only create COM components in the Page_Load event handler or later. The runtime does not place the request into STA mode until after the constructor has completed, and creating an STA COM component before this time will lead to additional marshalling overhead between apartments

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like