|
Ok. In your post you don't assign the return value to any variable. Is this only missing from the post?
You could use following steps to find out the problem
- execute the procedure directly against the databse in Query window, see that it works
- check the properties of the TableAdapter, everything as it should be
- debug through ExistPreset-method and observe the values in variables, everything as it should be
- use plain SqlCommand to execute the procedure and see what it returns
|
|
|
|
|
|
|
|
Okay,
Since you get an exception, you should be able to see the source from the stack. You're right, it can be any class that is not instantiated, but stack trace should give you a good picture what class is causing the problem.
Also if you define the debugger to stop on exceptions, you should get to the actual location where the exception is occuring, where you can use QuickWatch to see which object is null.
When using debugger, remember that if the dataset definition is created by Visual Studio, it most propably has DebuggerStepThrough-attribute defined. Comment that out and you can debug inside generated code
|
|
|
|
|
|
Possible reasons for "Object reference not set to an instance of an object." on that line are:
- this = null (not likely)
- this.tableAdapter = null, is it?
- txtToolNumber = null, is it?
- return value of (this.presetTableAdapter.ExistPreset(txtToolNumber.Text)) = null (you can see this by debugging inside the method).
If none of those are null the problem is in my understanding inside ExistPreset-method, which (I presume) is genereted by VS, but still debuggable and observable (you can see this by right clicking on the method and selecting go to definition).
|
|
|
|
|
How do you dispose a generic list? Does myList = null solve the problem or does this only remove the reference to the instance and wait for the GC?
|
|
|
|
|
In general, you should wait for the garbage collector to clear up resources.
|
|
|
|
|
Disposing only cleans up the unmanaged resources held by the object. The object itself can only be cleaned up by the GC.
|
|
|
|
|
kensai wrote: does this only remove the reference to the instance and wait for the GC
Yes, that is correct. If you are completely desperate to get the memory back however, it is possible to force the garbage collection afterwards (however I wouldn't reccomend it unless you are having *severe* problems without)
Chris
|
|
|
|
|
Hi,
I am creating a custom action that override the uninstall of my setup.
the aim of the action is to remove files that the application creates (not created by the setup but on runtime).
How can I retrieve the path of where the installation is installed (like Application.StartupPath).
Thanks,
|
|
|
|
|
I worked on a similar functionality before and what I did is added the path as a value to a key in the registry during installation and then used that for uninstall.
|
|
|
|
|
Thanks, But I don't what to use the registry.
Does an another way exists?
|
|
|
|
|
the install directory is stored in the TARGETDIR property - you can pass that as a parameter to your custom action
|
|
|
|
|
Hi,
I got a problem in focus at a treeNode of a treeView on a panel by program.
Even I set treeNode1.Focus(), the node still can't get focus.
There is no problem where the treeView is just on the form without the panel.
How to solve it ?
Thanks
|
|
|
|
|
How about setting SelectedNode?
|
|
|
|
|
No, setting its the selectedNode and Focus() still cannot get it focused.
|
|
|
|
|
How to report a calculations' progress using a ProgressBar in a WinForms multi-threaded application? I want to utilize CPUs as much as I can and so use all (four) cores. After some googling the only thing I found is a suggestion to use a BackgroudWorker , but it supports only one thread for the same work.
The code looks like this:
Parallel.For(0, width, delegate(int x)
{
(***)
});
At (***) I tried the following:
1.)
progress.Value = x;
This thrown an exception of course.
2.)
progress.BeginInvoke(new Action (delegate {
progress.Value = x;
}));
Here the ProgressBar was updated after all calculation were finished. Tried to set a number of threads to 3 but it didn't change anything.
The implemetation of the Parallel class is robust imho.
Any help appreciated.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
There is a method that background workers have that is called "ReportProgress", and a event called "ProgressChanged" that triggers when the ReportProgress method is called. You can access the ProgressChanged from the original thread, unlike trying to directly access the progress bar via progressbar.value = x .
|
|
|
|
|
gajatko wrote: progress.BeginInvoke
Do not use BeginInvoke, as that will queue the invocation. Invoke should be sufficient.
|
|
|
|
|
Application hangs when using Invoke instead of BeginInvoke . From debugger, it stops on call to the Invoke method.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
You're making it harder than it has to be.
Use a BackgroundWorker object to perform the calculation, and call the UpdateProgress method at the desired interval.
private BackgroundWorker myWorker = BackgroundWorker();
private void InitEncryptWorker()
{
myWorker.WorkerReportsProgress = true;
myWorker.WorkerSupportsCancellation = true;
myWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(myWorker_DoWork);
myWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(myWorker_RunWorkerCompleted);
myWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(myWorker_ProgressChanged);
}
public void myWorker_DoWork(Object sender, DoWorkEventArgs e)
{
BackgroundWorker thisWorker = sender as BackgroundWorker;
int progress = 0;
for (int i = 0; i < 1000; i++)
{
if (!thisWork.CancellationPending)
{
thisWorker.ReportProgress(progress);
}
}
}
private void myWorker_ProgressChanged(object sender,ProgressChangedEventArgs e)
{
if (e.ProgressPercentage != this.progressBar.Value)
{
this.progressBar.Value = e.ProgressPercentage;
}
}
private void myWorker_RunWorkerCompleted(object sender,RunWorkerCompletedEventArgs e)
{
}
"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
|
|
|
|
|
This way you use only one thread for calculations and utilize 25% of quad core processors
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
C'mon, be a programmer. If your calculations take so long that it's bothersome, put some Thread.Sleep(10) calls in the loop somewhere.
"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
|
|
|
|