|
Hi guys,
I don't know why this error below keeps popping-up when I try to run my application and crashes.
Anybody seen this before? The application autoruns when the Windows startup.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.NotifyIcon.WndProc(Message& msg)
at System.Windows.Forms.NotifyIconNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks guys.
|
|
|
|
|
Im going to take a wild stab in the dark
nosferatu2000 wrote: System.NullReferenceException: Object reference not set to an instance of an object.
You have an object somewhere, which you try to call a method on, however that object is Null.
Null Reference exceptions are pretty cut and dry... not really that much ambiguity except maybe WHAT is actually null.
Debug your code, step through it until this error occurs and then you'll know what is null.
|
|
|
|
|
private void Form1_Resize(object sender, System.EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
this.Hide();
this.ShowInTaskbar = false;
this.Visible = false;
notify.Visible = true;
}
}
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{RestoreDisplay();}
private void RestoreDisplay()
{
Show();
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
this.Visible = true;
notify.Visible = false;
}
private void menuItem1_Click(object sender, System.EventArgs e)
{RestoreDisplay();}
private void menuItem2_Click(object sender, System.EventArgs e)
{Dispose(true);}
private void Form1_Load(object sender, System.EventArgs e)
{
this.Resize += new EventHandler(Form1_Resize);
notify.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);
}
i'm having problems restoring it from system tray.
the display is buggy. basically what happens is that the tabs contents dont appear. sometimes the treeview contents dont appear either.
i can get it up and down fine, however making it functional seems to be a little harder.
|
|
|
|
|
I am developing a system on Visual C#. What I want to do is create an icon on my desktop that will open up my system. I also want the icon to produce a loading page and then open the first window of my system. Any ideas? Please do not tell me to google it.
|
|
|
|
|
vandread1 wrote: Please do not tell me to google it.
*grin* Now why would we say that ?
I don't get your problem - do you want to create the icon in code ? Because otherwise, it sounds like your icon will be a shortcut to your exe, surely ? How does MySQL come into this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I accidently put mysql as the title. It doesn't have to do anything with my question. The icon is a shortcut to my exe, but I want a loading page to appear before my exe.
|
|
|
|
|
OK - so the question is, how do I get a splash screen ?
Basically, you want to store a picture in your resources for your exe, then you want to create a frameless dialog which shows the picture, and loads it from resources. Make it a member variable, call Show on it as your first step in initialisation, and then destroy it when your program is fully loaded and ready to go.
LMK if you need help with any of these steps.
Or you could use this[^] ( for what it's worth, I googled it )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've written an ftpclient app. All it does is connects to the host uploads a file and disconnects. In my code I close the socket. However when I try to reestablish the socket connection I get this exception:
Cannot access a disposed object named System.Net.Sockets.Socket.
In my close method I'm doing this:
<br />
FTPSocket.Shutdown(SocketShutdown.Both);<br />
FTPSocket.Close();<br />
in my open I'm doing this:
<br />
IPEndPoint ipend = new IPEndPoint(Dns.Resolve(Host).AddressList[0],Port);<br />
FTPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 60000);<br />
FTPSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 60000);<br />
FTPSocket.Connect((EndPoint)ipend);<br />
I'm not sure what I'm missing here. Any thoughts would be appreciated.
FYI I'm using an FTP class called FTPClient.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
MSDN says
The Close method closes the the remote host connection and releases all managed and unmanaged resources associated with the Socket. Upon closing, the Connected property is set to false.
I would guess that either Dispose() is being called on the socket object itself or on some object used by it internally.
I would just create a new socket object at the start of your open method. The garbage collector should clean up the previous one if it is still hanging around or you could put FTPSocket = null at the end of you're close method to be sure
|
|
|
|
|
okay this may be the dumbest question ever......but when you say create a new socket object you mean do this:
FTPClient ftpClient1 = null;
right?
I'm not up on all the terminology yet. Sorry
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Never mind I got it. Thanks for the help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Problem with Caching mutiple ArrayLists using a ToString value for
the name. The reason I am doing this is that I Cache.Insert multiple
arrays but if they all have the same array name they will all have the
same array (i.e. last array saved). I know I can hard code every set in the database, but I'm trying to make this code Dynamic for the long run.
I cannot seem to be able to extract the value from within the
"tmpfieldName" variable when I create an ArrayList
[e.g. ArrayList tmpfieldName.ToString() = new ArrayList();]
The data that is in the the SQL table consists of 2 columns. The first
column contains a fieldname value and the second column contains the fieldCode
value. This data is used in dropdown lists within multiple web pages.
It looks like:
fieldName fieldCode
name bob
name Ron
name Chuck
hair brown
hair blond
hair grey ... and so forth.
When I use the code below it returns a "Compiler Error Message: CS1002: ; expected"."
What method should I be using to get the string value for an ArrayList name?
I have tried this using a DataSet and DataTable[index} to cache and it does the same thing.
Thanks for any ideas
--------------------- sample code to load mutilple arrays --------------------------
SqlConnection dbConnection = new SqlConnection("server=" +cServer+";database=*********;
User ID=*********; Password=********");
SqlCommand mCommand = new SqlCommand("SELECT fieldName,fieldCode FROM dbo.AaFieldCodes
ORDER BY dbo.AaFieldCodes.fieldName", dbConnection);
dbConnection.Open();
SqlDataReader mReader = mCommand.ExecuteReader(CommandBehavior.CloseConnection);
string tmpfieldName = "firstGroup";
try
{
// Iterate through all returned records
bool firstRecord = true;
while(mReader.Read())
{
if (tmpfieldName = "firstGroup")
{
tmpfieldName = mReader.GetValue(0).ToString();
ArrayList tmpfieldName.ToString() = new ArrayList();
}
if (tmpfieldName != mReader.GetValue(0).ToString())
{
_cache.Insert(tmpfieldName, tmpfieldName.ToString());
tmpfieldName = mReader.GetValue(0).ToString();
ArrayList tmpfieldName.ToString() = new ArrayList();
}
tmpfieldName.ToString().Add (mReader.GetValue(1).ToString());
}
}
finally
{
_cache.Insert(tmpfieldName, tmpfieldName.ToString());
mReader.Close();
}
|
|
|
|
|
Rlearning wrote: ArrayList tmpfieldName.ToString() = new ArrayList();
I'm confused here. What is this supposed to do ? You can't call ToString ( which returns a string ) and give it a new value, let alone a value that is not a string.
Rlearning wrote: What method should I be using to get the string value for an ArrayList name?
Do you mean the variable name ? There isn't one. And all ArrayLists have the same value coming back from ToString. If you need to give them a name, can you derive a class from ArrayList ( or is it sealed ) ? You could use containment and still impliment the right interfaces to make your class generally useful, and add a string property for a name, if that is what you need.
It looks to me like the field name is what you want to use, after building an array list of values with the same field name. You have the field name there, and you know what you want on the other end, so why not use those values, dynamically, from the data table you're looking through ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the input.
The goal is to creat multiple arrays and store them in Cache memory. The problem I am having is with the "Cache.Insert(string, object)" Method. When I cache an array and give it a new "string" name, but use the same "object" name (ArrayList name) each time, it does not work. The results I am getting are that all Cached items point to the same "object" in memory. What it looks like to me is that the Cache.Insert does not take the array and put it in memory but rather creates a reference, like a pointer, to an existing location (object) in memory. This is why I'm trying to create a unique ArrayList name each time I create a new array. This problem also comes up when I use a DataSet and Datatables. The DataTable object reference is used by the Cache.Insert rather than the DataTable Name.
I hope I explained it so you can understand my problem.
My end goal is to take different groups of data from this SQL table and store them in different Cached items. If you have another way of doing this to achieve the same goal that would be great too.
Thanks
|
|
|
|
|
Rlearning wrote: What it looks like to me is that the Cache.Insert does not take the array and put it in memory but rather creates a reference, like a pointer, to an existing location (object) in memory
Ah.. in that case, call the Clone method to store a copy.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am still fairly new to C# and I am having some problems that I hope I can find an answer to soon. I am working on a program that reads in an XML file and then creates a bunch of checkboxes based off of what it finds in the file. Seeing how the number of checkboxes is dependent on what is in the XML, I decided to go with a checkedlistbox. I have modified the background color of the control so it looks like a normal grouping of checkboxes.
The two problems I am having are:
1) When you check a checkbox or uncheck it, the line is highlighted. I have looked for a way to change the highlight color but have not been able to so far. I want it to behave more like a checkbox so no hightlight.
2) I would like to increase the spacing between the items a bit. Again I have not been able to find a way to do this with the properties or events.
Thank you in advance. I hope it is not to much of an obvious solution as I have been ripping my hair out on this for several days.
Sean
|
|
|
|
|
This sounds like an owner-drawn listbox, here is a good tutorial:
http://www.codeproject.com/books/1930110286_10.asp
-- modified at 14:53 Friday 11th November, 2005
Basically you have to capture the draw event, measure the rectange and set its size using the measureItem event (to modify the vertical distance)
To change the highlighted text you set the solidbrush color to your background color to hide the highlight. SystemColors.Highlight comes from the OS and I don't think you can change it programmatically (at least easily)
Horizontal spacing is easy, just change the column width property
|
|
|
|
|
(Using VS2005)
hi!
I have added a tabcontrol to a form. I have linked a ContextMenuStrip to this tabcontrol. This ContextMenu only have one item called "closeMenuItem" to close one tabpage. Which is the problem? If I close tabcontrol.Tabpages(tabcontrol.selectedIndex)... I´m closing the active tabpage but no the page I have popup up the menu.
have I explained?Sorry, I´m don´t have a very good english.
The problem is that my contextmenu don´t close the proper page. How can I access to the page that is pointed by the mouse?
thanks and sorry again
|
|
|
|
|
What i am trying to do. When a user mouse clicks on a label control, label changes color. If user continues to holds down mouse button and moves over other labels, those labels will change to same color. Think of this as a multi-select.
The problem i am having is that the MouseEnter event of labels do not fire when i click and hold down the mouse button. So i am unable to detect when the mouse cursor enters a label control and then run code that changes the color. If i use a keydown instead of a mouse button to do multi-select, MouseEnter works fine.
How should i go about detecting when the mouse cursor enters a specific control while the mouse button is held down?
|
|
|
|
|
Is there a way where I can catch a condition say if a bool becomes false anytime in the code, it will catch that boolean, print out a failed message and exit?
The only ways I can see this work:
- Make a Thread to monitor the boolean. (Dont really want to do this as its not what I want to really do).
- Use throws on anytime on the if statement (I got lots of if statement everytime I do a function that returns a boolean statement).
Is there any other way like modify the try to catch the boolean instead of exceptions?
Kuira
|
|
|
|
|
Set and get your boolean via a property, so you can raise an event when it is changed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sounds like a plan, but how do you end the the current method that this boolean is on?
eg.
Property B {get{read data} set{IF failure [???]}}
Method A
{
[is there something I can do here to conditionalize if B is not true do something]
B = test1;
B = test2;
[this is where it catches the condition when its not true]
}
-- modified at 19:26 Thursday 10th November, 2005
|
|
|
|
|
Kuira wrote: how do you end the the current method that this boolean is on?
Oh, OK. Why do you want to do that ? Surely there's better ways to do it ( for example, check the boolean in the method in question ). If you wanted, you could throw an exception here and put a try/catch in the method that sets it, but it's really convoluted, and ugly.
If I get this right, your calling code will change a boolean, and if it sets it to the right value, the rest of that function won't execute ? Why do you need to do this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a testing procedure that calls my other testing procedures. If one of them fails the test, I want to be able to catch it, store it as a message and pass it back to the originator. Writing the error and saying this test failed, please try again and telling him to recall this function when he is ready for his set of data to be tested again.
That way, the originator will only need to call one function, I will pass him the message pass or fail, and everyone is happy.
I dont like the idea of
bool = test 1
if bool is true (return message)
bool = test 2
if bool is true (return message)
... Imagine I have 100 tests
|
|
|
|
|
Kuira wrote: I have a testing procedure that calls my other testing procedures.
Have the testing procedures return a boolean value indicating success or failure (true or false). Then represent those procedures with delegates. Put the delegates into a collection or an array. From the main testing procedure, iterate through the collection invoking each delegate until one returns false.
If one of the testing procedures fails, that is returns false, make note of which procedure it is (this could involve some extra work to associate some information with each procedure delegate, but it should be pretty straightforward), and return the appropriate error message.
To be honest, I'm not entirely clear on what you're trying to do, so this suggestion is in part guesswork. Hope it helps.
|
|
|
|