Recently I've encountered two highly annoying bugs in the framework,
anyone who knows how to solve them would be most appriciated.
1) I'm trying to do Process.Start(url); and get a Win32Exception, after
quite a bit of testing I found out that the reason for this is that I
didn't have STAThread attribute. Process.Start(url) throws when I don't
have an attribute at all, or when I have MTAThrea, anyone can tell me
why?
I looked around, and it seemed that many other people have encountered
this problem. I've the workaround, but I want to know what is going on
here!
2) The following code throw an exception and abort the program, it
shouldn't!
public static void SetExceptionHandlers()
{
System.AppDomain.CurrentDomain.UnhandledException+ =new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
System.Windows.Forms.Application.ThreadException+= new
System.Threading.ThreadExceptionEventHandler
(Application_ThreadException);
}
public static void HandleException(Exception ex)
{
if(ex==null)
return;
using(DetailedErrorInfo dei = new DetailedErrorInfo(ex))
{
dei.ShowDialog();
}
}
private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
HandleException(e.ExceptionObject as Exception);
}
private static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
{
HandleException(e.Exception);
}
[ STAThread()]
public static void Main(string [] args)
{
SetExceptionHandlers();
Test();
Console.WriteLine("Test passeed");
private void Test()
{
throw new InvalidOperationException("Test");
}
There is nothing wrong here as far as I can tell, but it still will give
me the silly default dialog. The whole point is to have a better dialog
there!
3) Not related to bugs, but does anyone knows whatever there is a way to
know at *runtime* whatever this is a debug or release build? 10 1731
Ayende Rahien wrote: 3) Not related to bugs, but does anyone knows whatever there is a way to know at *runtime* whatever this is a debug or release build?
The main problem that you first have to define: What is the different
between release and debug build?
From the CLR-View the only difference is the
"System.Diagnostics.DebuggableAttribute"-Attribute.
This attribute has two properties:
- IsJITTrackingEnabled
- IsJITOptimizerDisabled
If both are "false", then you have a release build.
See: http://msdn.microsoft.com/library/en-
us/cpref/html/frlrfsystemdiagnostics
debuggableattributeclasstopic.asp
An other difference might be the generation of PDB-Files. But the
current VS2002/2003 only support the generation of PDB-files with boths
attribut-members set to "true".
If you compile via command-line you can build a release version (no
DebuggableAttribute-Attribute or both set to false) AND have a PDB-file
generated.
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
Ayende Rahien wrote: 1) I'm trying to do Process.Start(url); and get a Win32Exception, after quite a bit of testing I found out that the reason for this is that I didn't have STAThread attribute. Process.Start(url) throws when I don't have an attribute at all, or when I have MTAThrea, anyone can tell me why?
Can you please provide a working example !?
Are you using "UseShellExecute" or normal start with "CreateProcess" !?
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
"Jochen Kalmbach" <no********************@holzma.de> wrote in message
news:Xn**********************************@207.46.2 48.16... Ayende Rahien wrote:
1) I'm trying to do Process.Start(url); and get a Win32Exception, after quite a bit of testing I found out that the reason for this is that I didn't have STAThread attribute. Process.Start(url) throws when I don't have an attribute at all, or when I have MTAThrea, anyone can tell me why?
Can you please provide a working example !? Are you using "UseShellExecute" or normal start with "CreateProcess" !?
This is the full source code that cause the problem:
public class Test
{
[System.MTAThread()]//NOTICE this, without this, everything works.
public static void Main(string []args)
{
System.Diagnostics.Process.Start("http://www.google.com");
}
}
Cause Win32Exception with "The requested section was not present in the
activation context"
I can't repreduce the problem of no *Thread attribute in a simple example
(complex stuff about threading and winforms.
The ThreadAttribute can't be the problem source.
Willy.
"Ayende Rahien" <Ay****@no.spam> wrote in message
news:er**************@tk2msftngp13.phx.gbl... "Jochen Kalmbach" <no********************@holzma.de> wrote in message news:Xn**********************************@207.46.2 48.16... Ayende Rahien wrote:
> 1) I'm trying to do Process.Start(url); and get a Win32Exception, after > quite a bit of testing I found out that the reason for this is that I > didn't have STAThread attribute. Process.Start(url) throws when I don't > have an attribute at all, or when I have MTAThrea, anyone can tell me > why?
Can you please provide a working example !? Are you using "UseShellExecute" or normal start with "CreateProcess" !?
This is the full source code that cause the problem:
public class Test { [System.MTAThread()]//NOTICE this, without this, everything works. public static void Main(string []args) { System.Diagnostics.Process.Start("http://www.google.com"); } }
Cause Win32Exception with "The requested section was not present in the activation context"
I can't repreduce the problem of no *Thread attribute in a simple example (complex stuff about threading and winforms.
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl... The ThreadAttribute can't be the problem source.
Test it, then.
Using MTAThread - exception
Using STAThread - working
Not using at all - works (but I'd some problems with that)
Sorry my bad, that's why I'm allways using ProcessStartInfo to start an
external process, that way I wont be bitten by shell COM threading issues.
ProcessStartInfo sti = new ProcessStartInfo("IExplore.exe");
sti.Arguments = "www.google.com";
sti.UseShellExecute = true;
Process.Start(sti);
Willy.
"Ayende Rahien" <Ay****@no.spam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... "Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message news:e4**************@TK2MSFTNGP10.phx.gbl... The ThreadAttribute can't be the problem source.
Test it, then. Using MTAThread - exception Using STAThread - working Not using at all - works (but I'd some problems with that)
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl... Sorry my bad, that's why I'm allways using ProcessStartInfo to start an external process, that way I wont be bitten by shell COM threading issues.
ProcessStartInfo sti = new ProcessStartInfo("IExplore.exe"); sti.Arguments = "www.google.com"; sti.UseShellExecute = true; Process.Start(sti);
And that is nice, but what if the user's default browser is
Mozilla/Opera/Netscape/Non-IE?
read before responding
ProcessStartInfo sti = new ProcessStartInfo("IExplore.exe"); (use
path/opera.exe) And that is nice, but what if the user's default browser is Mozilla/Opera/Netscape/Non-IE?
I don't *know* what the user's default browser is!
Yes, I can find out, but that is too much trouble.
I can also do this:
Process.Start("cmd /c start " + url);
Which will also work (and give me the default browser), but I don't want to
use this (works on winnt only), I want to know what is wrong here.
"Spire" <sp**********@mail.com> wrote in message
news:c4**********@ls219.htnet.hr... read before responding
ProcessStartInfo sti = new ProcessStartInfo("IExplore.exe"); (use path/opera.exe) And that is nice, but what if the user's default browser is Mozilla/Opera/Netscape/Non-IE?
What is wrong here is simply that doing it 'your way - using Shell API's
under the covers', the calling thread must be running in an STA.
For more info read this (especially the remarks): http://msdn.microsoft.com/library/de...tarttopic2.asp
Willy.
"Ayende Rahien" <Ay****@no.spam> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl... I don't *know* what the user's default browser is! Yes, I can find out, but that is too much trouble.
I can also do this: Process.Start("cmd /c start " + url);
Which will also work (and give me the default browser), but I don't want to use this (works on winnt only), I want to know what is wrong here.
"Spire" <sp**********@mail.com> wrote in message news:c4**********@ls219.htnet.hr... read before responding
ProcessStartInfo sti = new ProcessStartInfo("IExplore.exe"); (use path/opera.exe) > > And that is nice, but what if the user's default browser is > Mozilla/Opera/Netscape/Non-IE? > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mudge |
last post by:
Hi,
I'm trying to help my hosting company decide whether or not to upgrade to
php 5. My hosting company does not want to upgrade to php 5 if it has bugs
that would cause problems. So i'm doing...
|
by: kartik |
last post by:
there seems to be a serious problem with allowing numbers to grow in a
nearly unbounded manner, as int/long unification does: it hides bugs.
most of the time, i expect my numbers to be small. 2**31...
|
by: Brett C. |
last post by:
Anthony Baxter, our ever-diligent release manager, mentioned this past week
that Python 2.3.5 will most likely come to fruition some time in January (this
is not guaranteed date). This means that...
|
by: Alex Bell |
last post by:
There have been several postings recently dealing with bugs in
Internet Explorer. Can anyone point me to a review of these bugs and
how to work around them?
Regards, Alex
|
by: Prashanth Badabagni |
last post by:
hi,
i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
C language whether programming or syntactical BUGS ....
Thanks in advance ...
Prashanth Badabagni
|
by: David Teran |
last post by:
Hi,
we are currently using another database product but besides some
licensing issues we are finding more and more problems with the
database. We are evaluating PostgreSQL and it looks quite...
|
by: TheSteph |
last post by:
Using : Windows 2000 Pro SP4 / VS.NET 2005 / .NET 2.0 / C# - All updates
done.
I have several bugs when I use the DataGridView : When scrolling (or after
scrolling) the grid have these...
|
by: Alan Silver |
last post by:
Hello,
Having discovered what I believe to be two CSS bugs in IE7, I have
submitted bug reports to MS. AFAIK, these don't get acted on until they
receive votes form others to say they are worth...
|
by: Gary Peek |
last post by:
Can anyone tell us the browsers/versions that exhibit errors
when tables are nested too deeply? And how many levels of
nesting produces errors?
(not a tables vs CSS question)
|
by: CJ |
last post by:
Hello:
We know that C programs are often vulnerable to buffer overflows which
overwrite the stack.
But my question is: Why does C insist on storing local variables on the
stack in the first...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |