Re: Serious bug in .NET framework 2.0 - Finally the solution
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Mon, 27 Mar 2006 23:24:39 +0200
"Elmue" <abuse@xxxxxx> wrote in message
news:OAdVCNdUGHA.2276@xxxxxxxxxxxxxxxxxxxxxxx
| Hi
|
| Finally I solved the problem without the help of this newsgroup.
| Here is the solution for all those, who encounter a problem of the
following kind:
|
| If you should find,
| -- that your application crashes in a strange way (no try .. catch helps)
| -- may be the crashes look different each time and seem unreproducable
| -- that the function which crashes your appplication uses COM (e.g.
IShellLink)
| -- that you compiled with Visual Studio 2003 for Framework 1.1
| -- that your application runs perfectly if ONLY framework 1.1 is
installed.
| -- that your application crashes if you ADDITIONALLY install framework 2.0
| -- that your application STILL crashes EVEN after you UNINSTALLED
framework 2.0
| then this tip might help you:
|
| If you call the function which accesses COM
| (no matter if in C# via COM import or in managed C++)
| from a thread then you must write:
|
| Thread i_COMThread = new Thread(new ThreadStart(ThreadProc));
| i_COMThread.ApartmentState = ApartmentState.STA;
| i_COMThread.Start();
|
| and the sun will shine again !!
|
| Elmü
|
Can you also explain why it failed after you installed V2 of the framework?
Threads enter the MTA unless you initialized them otherwise, this behavior
did not change from V1 to V2. Also why are you suggesting to initialize all
your threads that use COM interop to enter the STA? Threads should use a COM
component's compatible apartment (STA or MTA). If you initialize a thread to
enter a STA and your COM component is 'Free' threaded, you'll take a huge
marshaling overhead and the sun will shine less brightly ;-).
Willy.
.
- Follow-Ups:
- References:
- Prev by Date: Re: initialising strings
- Next by Date: Re: XmlIncludeAttribute puts the cart before the horse.
- Previous by thread: Re: Serious bug in .NET framework 2.0 - Finally the solution
- Next by thread: Re: Serious bug in .NET framework 2.0 - Finally the solution
- Index(es):
Relevant Pages
|