|
I've created a second windows form in my project, which is a simple dialog which I want to use for 'search and replace' in my text fields. It has a couple of text fields and a few buttons, all created via the wizards. When I create an instance of my dialog, it crashes in the line:
this.ResumeLayout(false);
with a NullReferenceException. I don't see why - I create the dialog using new, and it all seems kosher to me. Does anyone have any suggestions ?
public SearchDialog(bool bReplace, string sText)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_sText = sText;
m_bReplace = bReplace;
if (!bReplace)
{
Replace.Enabled = false;
All.Enabled = false;
}
//
// TODO: Add any constructor code after InitializeComponent call
//
}
SearchDialog sd = new SearchDialog(false, m_XMLObject.GetXML());
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I don't see why that line would cause it to crash, since the code is executed within a non-static constructor the this reference has to exist
Have you installed SP2?
If you haven't, it might actually be crashing on the previous line; but due to a bug (fixed in SP2) it shows the wrong line.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
If you haven't, it might actually be crashing on the previous line; but due to a bug (fixed in SP2) it shows the wrong line.
That was a bug and i thought that was normal.
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|
|
No, I haven't. The previous line was one that took an array of controls, all of which have had 'new' called on them, and when I comment it out, it still crashes. Basically the Winforms wizards are crap, is my conclusion, as every bit of the code in question was generated by the wizard and none of it was complex.
I gave up in the end, deleted the dialog and did it on the main form.
Thanks for the advice, I'll get SP2 ASAP.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Christian Graus wrote:
Winforms wizards are cra
Yes they are
I just hate getting all that InitializeComponent() junk, plus some random cleanup function I forget the name of. The code is rather inefficient and ugly too! (No tab alignments).
I just use Windows Forms to calculate coordinates then do it myself.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
Try Stepping through the code and look at the "Auto" window to see what object is null when the exception occurs. Since you haven't posted the code for InitializeComponent() cant't say anything more.
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|
|
Hi,
Atm, i am developing small application, as usual, there is remote object, client and server program which windows based program.
What i'm trying to do is, when I start the client program, (of course I start the server first), the client program will call the remote object, and the remote object will insert a new row in ListView which resides in my server program. The data that I pass is just the IP address.
How can u do this? I don't want to store in database, and ask the server program to retrive new data every 10 secs.. what I want is, remote object tell the server that there is a new data to be displayed.
Thanks
Eka
|
|
|
|
|
It's not quite clear if the server program and remote object are running in the same process or different ones. Anyways i think what you need is to use Remote Events.
Declare an event in the Remote Object which is fired whenever there is new Data. Then make the server program hook onto that event and that will do what you want, i think
Ofcourse i am assuming here that the server communicates with the remote object via remoting as well. You will face problems with Remote Events if you place the server and remote object in different directory.
Refer to the following site before implementing your solution. Look at the Remote Events example.
http://staff.develop.com/woodring
May the Source be with you
Sonork ID 100.9997 sijinjoseph
|
|
|
|
|
how to get point(x,y) where mouse click on desktop window
how to capture mouse events which will tell its position ,what button click etc.
is there any interrupt service of mouse where we can write our procedure ? to get mouse event info?
same for keborad ?
r00d0034@yahoo.com
|
|
|
|
|
please read that code and solve mine problem
tmpProcess = new Process();
tmpProcess.WaitForInputIdle();
tmpProcess.StartInfo.FileName="f:\\mirc59t";
try{
tmpProcess.Start();
while(! tmpProcess.Responding)System.Windows.Forms.Application.DoEvents();
}catch{}
tmpProcess.WaitForInputIdle();
IntPtr hWnd=tmpProcess.MainWindowHandle;
///////////////////////////////////////////////////////////
Control parent = Control.FromHandle(hWnd);
//////////////////////////////////////////////////////////
//Control parent = Control.FromChildHandle(hWnd);
if(parent!=null)
MessageBox.Show("parant not null");
/*foreach(Control child in parent.Controls)
{
IntPtr childHandle = child.Handle;
}*/
///////////////////////////////////////////////////////////
parent variable recive null that's why remaining code could not run.
it should not recive null because the process main window
contain two button and four Static members.
can any body tell why it recive null?
and what i have to do that it should not recive null?
r00d0034@yahoo.com
|
|
|
|
|
I think I had the same problem.
The problem is that you start the process and call process.MainWindowHandle before the Window is created. To test insert a breakpoint after process.Start() and wait for Mirc (hey 6.03 is out ) to open , and continue the code. The only programattical hack i came up with and see in some other code as well is do a Thread.Sleep(100), although this seems a bit clumsy and it doesnt gaurenttee that the handle has been created.
Anyways hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
Hi,
I don't like to have lots of .jpeg's floating around,
so I would like to neatly tuck them all away into an
ImageList ... but since they are to be used in several
different programs, where do I put them (that is: where do
I put the ImageList) ? - It would be nice to have a
resource file or a .dll where I could access them when
needed, but how ? ... any ideas ?
TIA
- Athos.
PS: Its easy to just put them into every program I make
(into the ImageList), but that would be a huge waste of
space since there are more then 500+ of them and all the
programs that need them are to be in the same package
(meaning they are shiped together) ...
PPS: Still new to the .NET Framework & C#, but I'm getting
there
|
|
|
|
|
Hello,
Check the ImageList wizard in www.codeproject.com
http://www.codeproject.com/useritems/imlmaker.asp
Have fun,
C:\>csc *.cs
Microsoft (R) Visual C# .NET Compiler
error CS2001: Source file 'brains.cs' could not be found
fatal error CS2008: No [brains.cs] specified
C:\>
|
|
|
|
|
Thanx ... that seems like just the thing I need ...
- Athos
|
|
|
|
|
Does this one ring a bell with anyone? I've got a .cs file I'm trying to compile and it's throwing this error.
error CS5001: Program 'C:\mydll.dll' does not have an entry point defined.
Real programmers don't document. If it was hard to write, it should be hard to understand.
|
|
|
|
|
There's no Main() in your program. Either add one, or use /target:library to create a dll
|
|
|
|
|
Hey what's up coders...
Okay I am going through a Hashtable using an enumerator does the size of the key in bytes actually hinder the time it takes to move through them?
Ie. if I use a short as the key m_htTable[short key] or I use a GUID would the key size really matter. I thought it was all done using address based access, meaning when travesing the hashtable a 32bit address is always used not the actual size of the key.
If anyone knows anything about this could they try and give me and idea on what is actually going on.
Thanks...
|
|
|
|
|
The size of the key doesn't matter.
Hashtable stores all of its keys as object references, so they're all the same size. Note that if you're using value types - such as short - they're boxed, and that can have performance implications if you do lots of accesses.
|
|
|
|
|
I am really frustrated here. I'm sure there is a simple answer but I can't see it.
I used VB.NET some time ago to write a web site, this time I thought I'd use C#.
If I want to access an event handler other than the default for a control in VB, I just use the two drop-down lists at the top of the code view. Select the control in the left-hand box, the event in the right hand. The IDE then does all the work for me (besides, the entire workload consists of having a method that "Handles" the event).
In C#, this isn't possible. The only item in the left-hand drop list is the page and the right-hand list only includes methods already coded.
I thought the answer would be to write the code by hand, for example
<br />
private void dgConfirm_EditCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)<br />
{<br />
dgConfirm.EditItemIndex = e.Item.ItemIndex;<br />
dgConfirm.DataBind();<br />
}<br />
But then somewhere I also need to add
<br />
dgConfirm.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(dgConfirm_EditCommand);<br />
This is easy enough in a Windows Form, where I've met the same problem, because I can add it to the constructor. But there is no constructor for a Web Form and the obvious methods (OnInit and InitializeComponent) are entirely within the "Windows Form Designer generated code" region.
I've learned the hard way that editing this is a bad idea.
So that's it, I'm officially out of ideas. Someone must know how to do this... please!!
Paul
|
|
|
|
|
In VS.NET click on the item you wish to add the event for.
Now open up the Properties panel and click the yellow lightning bolt symbol.
Now you should see all the events available, either double-click on the particular event to add a new (empty) event handler or click on the drop-down and choose the event handler you have already created.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Arrgh!
Thankyou James, I've been beating myself up about this most of the afternoon. Don't know why I didn't think of that. *sigh*
Paul
|
|
|
|
|
I am having a problem with serialization and deserialization of classes using the BinaryFormatter. I have two different programs and I want to serialize a class in the Test1 program and transfer it using sockets to the Test2 program and deserialize it into a replica class.
When I attempt to deserialize in the Test2 program, I get the following System.IO.FileNotFoundException:
File or assembly name Test1, or one of its dependencies, was not found.
Here is an example of how I am serializing:
SomeClass sc = new SomeClass();
sc.var1 = 12;
sc.var2 = m_strTemp;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms,(object)sc);
After receiving buffer of serialized data, here is an example of how I am deserializing:
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream(buffer,0,nBytesRead,true,true);
SomeClass sc = (SomeClass)bf.Deserialize(ms);
What am I doing wrong? How can I deserialize in an entirely different process, in a different program, on a different machine and not receive this error?
Thanks!
Donald
|
|
|
|
|
Classes in .NET are assembly specific, so if you and I both create a class called Foo with the exact same code but you have yours in the assembly donald.dll but mine is in the assembly james.dll they are considered incompatible types if the contents of the two assemblies differ.
The way to get around it is to place the classes that will be shared between the two applications into a separate assembly (class library to use VS.NET terms).
Then the client program and the server program both reference this assembly.
HTH,
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
That works very well... thank you very much!
|
|
|
|