|
|
You have to instantiate the ExceptionGlove object...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
It depends on where the exception is thrown.
If the class throws an exception during a call from the application, simply wrap the call in a try-catch to catch the exception.
If the class displays UI and throws an exception in a click event handler/timer/etc., use the Application.ThreadException event to handle the exception.
If the class creates a new thread and throws an exception there, you can display an error dialog from AppDomain.CurrentDomain.UnhandledException, but the AppDomain will usually terminate after the error. You'll have to host the class in a separate AppDomain to let your main program survive those cases.
That still won't help if the class calls into unmanaged code and crashes there - the process will terminate. You would have to host addins in a separate process to prevent that.
In my opinion, simply handling exceptions in the most common cases should suffice, but if you want more isolation, you should take a look at System.AddIns[^].
|
|
|
|
|
Hi,
There are to ways to register to event
for Example - for a button event
Button.Click += new System.EventHandler(this.baseButtonCancelPending_Click);
OR
Button.Click += this.baseButtonCancelPending_Click;
What is the difference?
Thanks,
Itay
|
|
|
|
|
Nothing. Second one is a syntactic shortcut and it is available from .NET2.0 onwards.
|
|
|
|
|
|
I am developing a Win app that pulls data from a datagridview control onto an excel spreadsheet.The app is doing this so far but I would like to knw if it is possible to present this data in a table .Is it possible, and if so how?
|
|
|
|
|
Ya if it is a Windows forms app in VS.NET there is a tool in the tool box (DataGridView).
You should be able to put data into it, and it should display it in a table. I have not tried it before but it looks
strait forward.
hope this helps!
static void main()
{
while (Robotics == cool)
{
Me.Build.Robots
}
}
|
|
|
|
|
i have a class
public class Command
{
public int Number;
public int[] Types= new int[30] ;
}
then i try to assign value of each by reading from a xml file
Command[] Querr = new Command[200];
XmlDocument Reader = new XmlDocument();
Reader.Load("MyXml.xml");
XmlNodeList List = Reader.SelectNodes("/MyXml/Common");
foreach (XmlNode node in List)
{
int i = int.Parse(node.Attributes["value"].InnerText);
Querr[i].Number = i;
}
I have error when Querr[i].Number=i, and it said" Object reference not set to an instance of an object"
How do i solve it? Thanks
|
|
|
|
|
yes why not you get error. You must intiate class before use. You can only use static objects without intiating.
foreach (XmlNode node in List)
{
int i = int.Parse(node.Attributes["value"].InnerText);
Querr[i]= new Querr();
Querr[i]= new Command();
Querr[i].Number = i;
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
modified on Tuesday, December 30, 2008 8:13 AM
|
|
|
|
|
what if i wanna assign the array of class
foreach (XmlNode node in List)
{
int i = int.Parse(node.Attributes["value"].InnerText);
Querr[i].Number = i;
int j= int.Parse(Xml node.Attributes["num"].InnerText;
Querr[i].Types[j] =12;
}
i have the same error with line : Querr[i].Type[j]=12 ?
|
|
|
|
|
why not man...ok take a simple example. You came to me and asked for a piece of land to stand 30 people in a row and i told you that "ok i will give you land", now you are trying to put those 30 people on that land without paying me. Do you think i will give that for free, no not at all. Thats why i threw you and says "object reference..."
hope this will help
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
But Types[] is atribute of class, how to set it to an instance?
|
|
|
|
|
public class Command
{
public int Number;
public int[] Types= new int[30] ;
}
Command[] tmp_cmd = new Command[30];
for(int a=0;a<tmp_cmd.Length;a++)
{
tmp_cmd[a] = new Command();
for (int b=0;b<tmp_cmd[a].Length;b++)
tmp_cmd[a].Types[b] = 123;
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
When you do
Command[] Querr = new Command[200];
you have allocated the array but not each array element
before you do Querr[i].Number = i you need to do:
Querr[i] = new Command();
|
|
|
|
|
Do as
int i = int.Parse(node.Attributes["value"].InnerText);
Querr[i] = new Command();
Querr[i].Number = i;
Cheers!!
Brij
|
|
|
|
|
|
Hi all,
this is kiran I am new to C# development and I have a issue that
I have to import R-project into C# for statistical analysis but
I don't know how to do this if possible can any one suggest me how can I proceed farther.
Thanks & Regards;
kiran
|
|
|
|
|
What is R-project ? The answer is no. You can use Process.Start to run another exe, but your interaction with the exe will be limited.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
thanks for replay
R-Project is an statistical computing and graphing language and tool its available in .exe file if u give any some more details about this problem it will be help full to me.
|
|
|
|
|
Can someone point me to a good article on how to subclass form and control objects? I want to take the base form and base form controls such as textboxes, listboxes, grids, etc. and create my own subclasses and store them in a library. Then I want to be able to easily refer to them on the toolbar instead of the base class objects when I design my applications.
Thanks!
Jim
|
|
|
|
|
Do you want some custom properties in the controls?Then you need to derived classes from textboxes, listboxes, grids, etc and add you properties and mathods.
Cheers!!
Brij
|
|
|
|
|
What I want to do is to first subclass the base form in .Net and add properties and methods to it that my app will use when I develop a module. Then I want to do the same thing with textboxes, comboboxes, and any other typed of control that I can place on a form. I want then to be able to (at design time) see and select my derived/subclassed objects, including the form on the toolbar and be able to select from that list.
I understand this is possible but I've not found an article on how this is done. Can someone point me to an article out there I can get to that will describe in detail how to do this?
Thanks!
Jim
|
|
|
|
|
Hi I have a problem that I cannot figure.
I have stripped the code down to a few lines that show the issue below.
Basically I have a worker thread that obtains an object and then makes a method call on that object that works fine. But when I return the object to the parent thread, from the parent thread the method call on that object fails. This is the problem. I have a guess about why it fails, but am not sure how to resolve it.
It may be that I need to do something extra to marshal the object back to the parent thread (as you can see I am not doing anything at all right now)
If the worker thread isn't marked as STAThread then the method call in the worker thread fails too, indicating that there is COM stuff going on in the background. I guess the problem is that the underlying object returned creates a COM object in the worker thread's apartment. When the object is invoked from the parent thread the method fails because the underlying COM object doesn't belong to the apartment of the parent thread. Does that sound at all correct?
Is there any way to resolve this?
class Program
{
static AutomationElement searchResult;
[STAThread]
static void ThreadFunc()
{
searchResult = FindObject();
searchResult.FindAllChildren();
}
[STAThread]
static void Main(string[] args)
{
Thread t = new Thread(new ThreadStart(ThreadFunc));
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
MyObject obj = searchResult;
obj.FindAllChildren();
}
}
}
|
|
|
|
|
Please specify what is fail? An Exception ? Do you have any error messages?
Natza Mitzi
|
|
|
|