Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / August 2006

Tip: Looking for answers? Try searching our database.

Mind Boggling Behavior

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shea - 30 Aug 2006 16:49 GMT
[STAThread]
       static void Main()
       {
           ApartmentState x =
Thread.CurrentThread.GetApartmentState();
           MessageBox.Show(x.ToString());
           // etc.
        }

Brings up a most annoying dialog box with my current three least
favorite letters in the English lanuage:

MTA

The previously described behavior results after the project was
upgraded from VS 2003 to VS 2005 ... I looked through the
project/solution settings but can not find anything that would seem to
"override" the [STAThread] attribute. Trying to set the apartment state
to STA results in another exception.

I'm probably missing something stupid - anyone have any ideas?

Thanks.
Shea - 30 Aug 2006 17:04 GMT
Found another topic which addressed the issue:

http://groups.google.ca/group/microsoft.public.dotnet.framework.interop/browse_t
hread/thread/8b9dcdea483f8962/1bafd56c45fc9c9e?lnk=st&q=STAThread+ignored&rnum=1
&hl=en#1bafd56c45fc9c9e


In short:

"Now I found the problem. It has nothing to do with the CoUnitialize().

I unchecked the "Enable the Visual Studio hosting process" for my
projekt an
everything is working fine. Thats the case for my old VS2003 projekt
which I
converted to VS2005.

For evaluation I added a new project (real VS2005 project) to my
solution
and paste in exactly the same main code as I had in my existing
project. If I
run this new application with "VS hosting process" enabled everything
working
fine too.

So there musst be a different handling of "converted" and "real" VS2005
projects. "

> [STAThread]
>         static void Main()
[quoted text clipped - 19 lines]
>
> Thanks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.