the best way depends on your programs structure and how you're going to use the data. two methods would be to make the list a static global so anybody can access it or pass the list to your forms as a parameter during construction. Again, it depends on how your program is structured but I'd generally prefer parameter passing to globals.
public class clientList
public List<client> data;
You have to "new" the internal list before you can use it. You make a new ClientList class but, the internal List is not created when you do. I suggest either A) Hiding the list internally (after you new it of course) you shouldn't expose members like that, or B) doing away with the containing class if it only has a List in it.
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
I am using MS Visio control in an application developed in C# (for .Net 1.1). I have a class MyAppContext that extends ApplicationContext. The application is started by calling Application.Run(myAppContext) where myAppContext is an instance of class MyAppContext.
The problem I face, is this, only under Vista, if a form containing Visio control is initialized, a NullRefrenceException is thrown. However, if I load the same form before initializing myAppContext, it works fine.
The same code works under XP and Windows 2003. I have also used 'Run as Administrator' option in Vista but the result is same.
Does anyone have a clue, what should I do to fix this problem?
by whom? at what line? catch the exception, look at its ToString() output, tell
Visual Studio to always show line numbers, and identify the faulty line.
A wild guess: you did something that is not thread-safe, your XP machine is single core
so it runs fine nevertheless, and your Vista machine is dual core, so it is bound to fail.
As I said, this is just a guess.
The exception stack trace shows that it is thrown somewhere in AxHost class. Unfortunately, I am not at my work place right now, so cannot attach the exact StackTrace. But will update as soon as I get it.
To explain further, I am writing the code flow that is something like as follows
// Main<br />
/*Line 1*/ VisioForm f = new VisioForm();<br />
/*Line 2*/ f.Show();<br />
/*Line 3*/ f.Close();<br />
/*Line 4*/ MyApplicationContext c = new MyApplicationContext; <br />
/*Line 5*/ Application.Run( c );<br />
There is a button on MainForm that has the same code as mentioned in Line 1-3 above in its click event. Now If I comment the code as in Line 1-3, the application will crash if the button on main form is clicked. But works fine, if I leave it there.
More interestingly, If the lines 1-3 are moved between line 4 and 5, the application will still crash with the same message.
This makes me believe that there is something wrong when using ActiveX controls inside a custom application context on Vista.
1. Yes, it is form.Show() and form.Close(). This is actually a work around to make the application work on Vista. After placing these lines, VisioForm opens fine whenever the button on MainForm is clicked.
2. The code does has try-catch. Problem is I cannot get my form open. I will put the exception log here.
3. Main module has STA Attribute.
Actually if I open and close the form containing Visio control (Line 1-3 in my previous post), before application context initialization, my application works fine on Vista. but If I remove these lines, it starts crashing whenever the VisioForm is initialized.
Hi Guys. I have an opendiledialoge. If I click Cancel then the whole project closses. Any idea how I can set it to return to the main form if the user clicks on cancel instead of having the whole app closing??
Here is the code.
if (openFileDialog1.ShowDialog() != DialogResult.OK)
Excellence is doing ordinary things extraordinarily well.