vs strange behavior …
Hi, All!
Could anyone explain me, how could it be?
Thanks, Alex.
vs strange behavior …
Hi, All!
Could anyone explain me, how could it be?
Thanks, Alex.
I still find the linked answer a bit hard to take, especially because the OP acknowledged that he did not in fact have a DLL with the same name as the EXE. I also can't repro it.
However, there's some credibility to the explanation, I noticed that Fusion does something weird when it is asked to search for an assembly. You can see this at work with Fuslogvw.exe, enable the "Log all binds" option. Odd thing is, it searches for both a DLL and an EXE when asked to load an assembly. Here's a snippet from a log entry for a test console application:
LOG: Attempting download of new URL file:///C:/projects/ConsoleApplication3/bin/Debug/ConsoleApplication3.DLL.
LOG: Attempting download of new URL file:///C:/projects/ConsoleApplication3/bin/Debug/ConsoleApplication3/ConsoleApplication3.DLL.
LOG: Attempting download of new URL file:///C:/projects/ConsoleApplication3/bin/Debug/ConsoleApplication3.EXE.
LOG: Assembly download was successful. Attempting setup of file: C:\projects\ConsoleApplication3\bin\Debug\ConsoleApplication3.exe
LOG: Entering run-from-source setup phase.
Scroll to the right to see how it first looks for a DLL. And how it looked in a subdirectory with the same name as the assembly. Strange and plenty of potential for DLL Hell here. With the failure mode that the CLR probes the wrong assembly for the [STAThread] attribute somehow. Also explains the strange "Closed as external" dismissal of the Connect feedback article, Fusion is owned by the Windows group at Microsoft, not DevDiv.
Anyhoo, indications are that simply renaming the output file will fix your problem. Project + Properties, Build tab, Output path setting.
I'm not an expert on the inner workings of a debugger, but I would have thought that values displayed in a watch window are evaluated by a Visual Studio thread, not the application's main thread (which is paused in the screenshot).
Hence I don't see a contradiction, the watch window is just saying that the Visual Studio thread is MTA.
Try using Debug.Write
to display the main thread's apartment state.