Intriguing MTA v STA bug  
Author Message
rochdalemark





PostPosted: Top

Visual C#.Net >> Intriguing MTA v STA bug

Excerpt as follows:



We have developed a .Net application that makes use of WebServices to access
a PeopleSoft (Oracle) database using the PeopleSoft 8.4 COM API. When the
application is tested by a single user, everything works fine and no errors
are generated. When multiple users test the system a number of different
and seemingly random errors begin to occur. We created an ASP based version
of the application that still calls the PeopleSoft COM API and it does not
generate any errors with one or many users testing it. The PeopleSoft COM
API is built as a TLB file named "PeopleSoft_PeopleSoft.tlb" from the
PeopleSoft Application Designer. A registry file is also generated and has
to be run to update the system registry before the COM API can be
referenced. Within the registry file there is an entry for another DLL call
"psapiadapter.dll" which has a parameter "Threadmodeling" that is set to
"Apartment". This means that the PeopleSoft COM API is set to run in an STA
(single threaded apartment) model. The default thread model for a .NET
application is MTA (Multiple Thread Apartment). Is it possible that our
errors are being caused by the fact that .NET is MTA and the PeopleSoft API
is STA? We tried setting the "Threadmodeling" registry parameter for the
PeopleSoft API to "Both" and found that all of the previous errors
disappeared, but a new error surfaced. The new error occurs intermittently
with multiply users testing the system. The error is a deadlock and
automatically causes the Web Server to reset. Our thought is that the
original errors have to do with the STA vs MTA situation and that when .NET
thought that it could run the PeopleSoft API in the MTA model those errors
went away, but the API was meant to be STA and so the thread deadlock
situations started to happen. We know that an ASPX page can be run in .NET
using the STA model by using aspcompat=true attribute in the <% Page ...%>
directive but we do not know how to make this adjustment for our application
that uses WebServices. The Webservices do not have page directives. We
think that a logical step would be to set the whole .NET architecture on our
server to run in some kind of STA model if that is even possible. Do you
have any ideas?

DotNet388