|
Hello,
I would like to replace standard runtime error box that displays when an unhandled exception occurs. The new standard error box should contain general unhandled error message along with the option to the user to express the circumstances of the error and send this information directly to our issue management system.
I know there is an AppDomain object that has UnhandledException event. I tried to bind a procedure to this event using AddHandler keyword. Actually I did the same what could be seen as the example in the MSDN library.
Unfortunatelly I found that this is not the way to go. The system default error message box is shown prior to mine. In addition, no all exceptions were catched by this error event handler in compiled application, although they were catched when the application was started from whithin IDE.
Does anybody any idea how to achieve desired functionality?
Thanks for any suggestions.
Vasek
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
You don't indicate if this is a web app, a fat client, a component, etc.
Assuming this is a fat client: the only way I can think of how to do this is to write a wrapper application that would be the starting point for all of your executions. It would be passed the name of the application to execute.
Then you would do a TRY and use reflection to load and execute the application. Your CATCH would trap all uncaught errors and you can handle the display of the error.
Of course, a simpler way is to just catch all of your errors.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
You don't indicate if this is a web app, a fat client, a component, etc.
It is a fat windows client.
theRealCondor wrote:
Of course, a simpler way is to just catch all of your errors.
I thought there is a simple way how to handle those errors they are left uncought. No way I advocate for not handling errors.
Anyway, thanks for your response
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
.NET magazine just did an article on how to do this. Do a google search for "Visual Studio Magazine - Hot .NET Tips - Catch All Exceptions in One Place"
|
|
|
|
|
I have an existing C# program which displays a form and then runs a worker thread that does some work. I have arranged for the form data to be stored within the Registry and restored when it gets run again.
What I would like to do is convert this fairly generic program to have the following features:
1. Check box that enables a NotifyIcon (Remove from Taskbar).
2. NotifyIcon that has a contextMenu that can show the form again.
(context menu has "Show Me" and "Exit" options)
I've read the tutorials on this site on creating NotifyIcon elements. However, I am not sure how to implement the above. Can someone provide some information?
-Adrian
|
|
|
|
|
You need to add a NotifyIcon to your form and to attach a ContextMenu to it.
|
|
|
|
|
I have a legacy COM In-Proccess server, which has an interface
function:
STDMETHODIMP CMyObj::GetData( /*[out]*/ DataStruct* pData )
{
...
}
where DataStruct is defined:
typedef struct AnotherStruct
{
long ID[4];
BSTR Name;
}AnotherStruct;
typedef struct DataStruct
{
AnotherStruct ArrayStruct[4];
long ArrayLong[4];
}DataStruct;
now, when i'm calling this function from the .NET (C# for the matter)
MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
obj.GetData( out data );
i get an exception: "Not enough storage is available to complete this
operation.", where the source of the exception was the interop.
I tried to look at the data struct and i found out that the C#
compiler, or the interop ( i don't know which one is responsible for
it ) ,that each primitve array in the struct was initialize
automaticly to the size that was defined in the COM typelib( for
example the ArrayLong was initialized to 4 int ) , but the array of
the struct ( ArrayStruct) was set to null.
I tried to modify the code to initialize it myself:
MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
data.ArrauStruct = new MYOBJECTLib.AnotherStruct[4];
obj.GetData( out data );
but it didn't work.
worth mentioning that when i modified the struct:
typedef struct DataStruct
{
AnotherStruct ArrayStruct;//ArrayStruct[4]
long ArrayLong[4];
}DataStruct;
everything worked ok.
anybody???
Amir Harel
|
|
|
|
|
I guess it's about time to do struct marshaling yourself[^].
|
|
|
|
|
my main application had started a process X and i want my application to be notified when that process had been terminated externally by OS.
i try:
X.EnableRaisingEvents = true;
but what is the event method declaration for my main application's to handle exit event triggered by process X?
thank you.
regards
yccheok
|
|
|
|
|
I'm not sure if you are looking for a event notification, in case you just want to wait until the process is over, you can try WaitForExit method on the Process class.
Cheers
Kannan
|
|
|
|
|
actually, i want two process can be run at the same time. it seems that Richard_D had provided me the solution will test it out 2night.
anyway, thanks for the suggestion.
regards
yccheok
|
|
|
|
|
Assuming X is a System.Diagnostics.Process variable:
...
X.EnableRaisingEvents = true;
X.Exited += new EventHandler(ProcessExited);
...
void ProcessExited(object sender, EventArgs e)
{
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
the follwing code compiled no problem and i make an conclusion that WMEncoder is a class instead of an interface.
WMEncoder e = new WMEncoder();//Yahoo!No problem at all!
when i try to make a derived class from WMEncoder (this is because i want to call the Finalize method explicitly):
-----------------------------------------------------------
using System;
using WMEncoderLib;
namespace GOWatch
{
///
/// Summary description for WMEncoderEX.
///
public class WMEncoderEX : WMEncoder
{
public WMEncoderEX()
{
//
// TODO: Add constructor logic here
//
}
}
}
-----------------------------------------------------------
i get 95 lines of similar error
d:\documents and settings\administrator\my documents\visual studio projects\gowatch\wmencoderex.cs(9,15): error CS0535: 'GOWatch.WMEncoderEX' does not implement interface member 'WMEncoderLib.IWMEncoder2.SetLocaleID(int)'
isn't that WMEncoder is already a class instead of interface? why i am still forced to implement interface WMEncoderLib.IWMEncoder2 members?
thank you.
regards
yccheok
|
|
|
|
|
yccheok wrote:
the follwing code compiled no problem and i make an conclusion that WMEncoder is a class instead of an interface.
WMEncoder e = new WMEncoder();//Yahoo!No problem at all!
This is one of my problems with C#, or at least it's compiler, while this may be a valid statement when dealing with C++, C# allow value types to make this same declaration, for example:
<font color="green">
struct Val
{
int X;
}
<font color="green">
Val v = new Val();
<font color="green">
Console.Write(v.X.ToString());
I really don't know about WMEncoder , however you may be dealing with something else.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Ok, I'm not sure of this could be the problem, but may be you would have to implement a set of interfaces on your derived class (by simply calling the base class methods or with your own implementation).
Cheers
Kannan
|
|
|
|
|
simple question for the jedi -
I always thought that protected internal combined the access modifiers into protected (only in inheritance heirarchy) and internal (only in project).
Apparently it is an either-or however: protected internal means both inheritance heirarchy or within project.
My question is *why*. Can anyone think of a good example where this might be useful?
Thanks in advance -
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
The difference:
internal
Accessible only by methods in the defining assembly.
protected internal
Accessible only by the methods in this type, any derived type, or any type defined in the defining assembly.
This is directly from Applied .NET Framework Programming by Jeffery Richter, essentially protected internal give you more latititude when creating assemblies that provide extensibility through inheritance.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
I've been trying to teach myself C# and web related programming with the beta version of Microsoft Visual Studio 7.0. I've tried to use the web controls but when I try and execute a simple example, the control does not appear in the browser (labels show up but buttons, etc do not). Any suggestions? I have a feeling it's a configuration problem (with IIS, browser, or something else).
Any help or suggestions appreciated.
Joe
|
|
|
|
|
Are you remembering to include the runat="server" attribute? in the asp:Button tag?
|
|
|
|
|
It shows runat="server" in the HTML section. Is there another location that this needs to go?
Any other thoughts?
Joe
|
|
|
|
|
who to get window directory path programatically?
r00d0034@yahoo.com
|
|
|
|
|
Look at System.Environment
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Try this:
FileInfo file = new FileInfo(Environment.CurrentDirectory);
all the best,
=====================
http://wasp.elcat.kg
|
|
|
|
|
i want to start a Process
whose path is on network say
\\imran1\folder1\folder2\some.exe
where imran1 is computer name but when i create an object of Process and called its start method
it did not start the process whoes path is at network only ((i.e path)\\imran1\folder1\folder2\some.exe)
but it sucessfully start the process at local drive and also on those drives that are mapped for network path.
but THE requirement of my application is the common path for each computer of the network
i am using xp prof.i have full permission and if i run this exe manually it execute sucessfully.
i am putting this question second time (one person(thanks for him) has give me the idea of map network drive but could not tell the reason for that)
can any body solve my problem?
r00d0034@yahoo.com
|
|
|
|
|
I'm not entirely clear on what you are trying to do here, but I suspect that you want this process to run in the other box, not in your local box. I also suspect that when the target exe was on a mapped drive, it ran in your box, rather than on the remote node. If my guesses are correct, then this is not something you can accomplish with a local process object in your box. You will, instead need to use remoting (see the help on System.Remoting namespace). This is a bit more complicated, because what you are describing makes yourr machine the 'client' and all others the 'server' in a remoting scenario. this means you would need some always running 'listener' task on all the remote machines to provide a tcp or udp reciever for the 'run' command, the 'listener' would actually create the process object and start the target.
If you really just want a local process that was started by loading the executable located on the remote computer into local memory, then you would at least have to share the folder on the remote machine, and at least temporarily (net use or the equivalent API call) map it.
If none of this makes sense, then perhaps If you provided some more detail on exactly what you are trying to do and the rational for the "same path" requirement...
R
|
|
|
|