|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
STA and MTAHi,
We have a dozens of VB6 components, developed some 5 years before, we have now few .Net components which references these files. Ideally we are using Biztalk server and referencing these VB6 components into that, what happens is that during actual transaction with several instances, the process(biztalk) gets automatically shutdown. on researching the problem it was found that all VB6 compentes were STA and so when loaded into memory it caused a deadlock problem. The solun ideally is to convert all the vb6 componets to .net components, but as of now this is practically impossible. can any one suggests an alternate method so that the process goes with MTA instead of STA or atleast any ways to minimise the deadlock condition?
Show quote
Hide quote
"Venkat" <Ven***@discussions.microsoft.com> wrote in message Simple solution is to create/access instances of those COM objects on/from a news:71D078A4-EBFE-4A92-A585-915F239D62BD@microsoft.com... > Hi, > We have a dozens of VB6 components, developed some 5 years before, we > have now few .Net components which references these files. Ideally we are > using Biztalk server and referencing these VB6 components into that, what > happens is that during actual transaction with several instances, the > process(biztalk) > gets automatically shutdown. > > on researching the problem it was found that all VB6 compentes were STA > and > so when loaded into memory it caused a deadlock problem. The solun ideally > is > to convert all the vb6 componets to .net components, but as of now this is > practically impossible. > > can any one suggests an alternate method so that the process goes with MTA > instead of STA or atleast any ways to minimise the deadlock condition? STA threads, that is initialize your threads as STA by setting the ApartmentState to STA before starting the thread. Willy. Hi Willy,
Maybe as a MVP you would know this... Do you know why the pages at MSDN which discribes STA and MTA are disappiring ? -- best regards stic "stic" <stefan.tural***@gmail.com> wrote in message I'm not clear on what you mean with "disappiring", but if you mean there is news:1118393188.768408.122490@o13g2000cwo.googlegroups.com... > Hi Willy, > > Maybe as a MVP you would know this... > Do you know why the pages at MSDN which discribes STA and MTA are > disappiring ? > > -- > best regards > stic > no info about STA/MTA on msdn, you could do a search for "single threaded apartment" on msdn and you will get a huge list of hits. One of them is: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/cb62412a-d079-40f9-89dc-cce0bf3889af.asp Or are you looking for something else? Willy. I didnot understand, can you be more specific with an example?
venkat. Show quoteHide quote "Willy Denoyette [MVP]" wrote: > > "Venkat" <Ven***@discussions.microsoft.com> wrote in message > news:71D078A4-EBFE-4A92-A585-915F239D62BD@microsoft.com... > > Hi, > > We have a dozens of VB6 components, developed some 5 years before, we > > have now few .Net components which references these files. Ideally we are > > using Biztalk server and referencing these VB6 components into that, what > > happens is that during actual transaction with several instances, the > > process(biztalk) > > gets automatically shutdown. > > > > on researching the problem it was found that all VB6 compentes were STA > > and > > so when loaded into memory it caused a deadlock problem. The solun ideally > > is > > to convert all the vb6 componets to .net components, but as of now this is > > practically impossible. > > > > can any one suggests an alternate method so that the process goes with MTA > > instead of STA or atleast any ways to minimise the deadlock condition? > > Simple solution is to create/access instances of those COM objects on/from a > STA threads, that is initialize your threads as STA by setting the > ApartmentState to STA before starting the thread. > > Willy. > > > Just to make sure we are talking about managed code here.
Your VB6 COM objects are created and accessed from from C# (.NET) managed code right? Willy. Show quoteHide quote "Venkat" <Ven***@discussions.microsoft.com> wrote in message news:D49BD631-6C53-412F-8CBA-805FB8E801BB@microsoft.com... >I didnot understand, can you be more specific with an example? > > venkat. > > "Willy Denoyette [MVP]" wrote: > >> >> "Venkat" <Ven***@discussions.microsoft.com> wrote in message >> news:71D078A4-EBFE-4A92-A585-915F239D62BD@microsoft.com... >> > Hi, >> > We have a dozens of VB6 components, developed some 5 years before, >> > we >> > have now few .Net components which references these files. Ideally we >> > are >> > using Biztalk server and referencing these VB6 components into that, >> > what >> > happens is that during actual transaction with several instances, the >> > process(biztalk) >> > gets automatically shutdown. >> > >> > on researching the problem it was found that all VB6 compentes were STA >> > and >> > so when loaded into memory it caused a deadlock problem. The solun >> > ideally >> > is >> > to convert all the vb6 componets to .net components, but as of now this >> > is >> > practically impossible. >> > >> > can any one suggests an alternate method so that the process goes with >> > MTA >> > instead of STA or atleast any ways to minimise the deadlock condition? >> >> Simple solution is to create/access instances of those COM objects >> on/from a >> STA threads, that is initialize your threads as STA by setting the >> ApartmentState to STA before starting the thread. >> >> Willy. >> >> >> The issue is that these methods are executing under BizTalk 2004. This means that the VB6 components are being called from ThreadPool threads which will enter the MTA and so all the VB6 components will join the Host STA (all of them will be serviced on the same thread) which is not good for scaleability.
One solution would be to write a .NET component that managed a custom thread pool of STA threads and ran a number of VB6 objects in those STAs. However, this is a non-trivial thing to build (and to some degree is a bit like reimplementing part of MTS ;-) ) - which thinking about it could be another solution - to host the VB6 components under COM+ and use COM+s threading infrastructure to provide the multiplexing. Regards Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk Just to make sure we are talking about managed code here. Your VB6 COM objects are created and accessed from from C# (.NET) managed code right? Willy. Richard,
I didn't look into Biztalk 2004 yet, but as it looks like it's not that "COM friendly" environment to live in. All STA (that is all VB6) objects will be hosted by the SINGLE STA host thread so all calls have to be serialized/marshaled which is not scalable at all, worse, who guarantees correct message pumping on this thread (which might explain the deadlock issues OP is referring to)? When one such component fails it brings down the whole process. So I'm in full agreement with you as to host these STA objects in a server type COM+ application or multiple applications, which is IMO the environment where most such "server" style components should live. Sure you pay the inter-process call overhead, but you get a lot back like multiple threads hosting STA's, security process control ... Willy. Show quoteHide quote "Richard Blewett [DevelopMentor]" <richardb@NOSPAMdevelop.com> wrote in message news:uuaCX9lbFHA.456@TK2MSFTNGP09.phx.gbl... > The issue is that these methods are executing under BizTalk 2004. This > means that the VB6 components are being called from ThreadPool threads > which will enter the MTA and so all the VB6 components will join the Host > STA (all of them will be serviced on the same thread) which is not good > for scaleability. > > One solution would be to write a .NET component that managed a custom > thread pool of STA threads and ran a number of VB6 objects in those STAs. > However, this is a non-trivial thing to build (and to some degree is a bit > like reimplementing part of MTS ;-) ) - which thinking about it could be > another solution - to host the VB6 components under COM+ and use COM+s > threading infrastructure to provide the multiplexing. > > Regards > > Richard Blewett - DevelopMentor > http://www.dotnetconsult.co.uk/weblog > http://www.dotnetconsult.co.uk > > Just to make sure we are talking about managed code here. > Your VB6 COM objects are created and accessed from from C# (.NET) managed > code right? > > Willy. > > how will it solve the problem if i change like that? any technical articles /
proofs, substantiating your view? pLS.. VENKAT. Show quoteHide quote "Willy Denoyette [MVP]" wrote: > > "Venkat" <Ven***@discussions.microsoft.com> wrote in message > news:71D078A4-EBFE-4A92-A585-915F239D62BD@microsoft.com... > > Hi, > > We have a dozens of VB6 components, developed some 5 years before, we > > have now few .Net components which references these files. Ideally we are > > using Biztalk server and referencing these VB6 components into that, what > > happens is that during actual transaction with several instances, the > > process(biztalk) > > gets automatically shutdown. > > > > on researching the problem it was found that all VB6 compentes were STA > > and > > so when loaded into memory it caused a deadlock problem. The solun ideally > > is > > to convert all the vb6 componets to .net components, but as of now this is > > practically impossible. > > > > can any one suggests an alternate method so that the process goes with MTA > > instead of STA or atleast any ways to minimise the deadlock condition? > > Simple solution is to create/access instances of those COM objects on/from a > STA threads, that is initialize your threads as STA by setting the > ApartmentState to STA before starting the thread. > > Willy. > > >
Other interesting topics
Newbie question: Thread access of form components
"Object does not match target type." using dynamic compiling & inv Covariance in delegates doesn't work with ValueType's? using C# DLL from plain C Converting string "2 1/2" to double events and eventargs OnPreRender ??? What is ? C# Eletitlement app - Can this be done Newbie question: Enum in Interface Excel C# API |
|||||||||||||||||||||||