If you're getting RPC_E_TOO_LATE it means CoInitializeSecurity has already been called, and I *think* the CLR loader probably calls it on your behalf. I've read conflicting things about when and if the CLR calls it. Anyway, in debugging mode you'll need to stop using the vshost mechanism because that calls CoInitializeSecurity().
Phil Wilson -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Andy Smith Sent: Wednesday, February 07, 2007 8:17 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] [STAThread] vs. WaitAll() Hi - I'm having a problem that I'm hoping folks here can help with. It involves COM issues as well as .NET, so please let me know if there's a better list to be posting this to.... I'm working on a console app (in C#) that is calling into a COM API (Virtual Server 2005) that requires the COM security level of 'Impersonate'. To accomplish that I'm calling CoInitializeSecurity() and it works, but only if I put [STAThread] on the Main method of my console app (gave an error about being unable to switch security contexts after starting). Never quite understood why, but it was fine until I started trying to use multiple threads in my app; I'm now getting an error on my WaitAll() call, saying I can't do this in an [STAThread] application. How do I solve this conflict? I have to have multiple threads to make working with Virtual Server practical. Thanks for any help you can provide. Andy =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com