Hello,
Thanks for you prompt reply.
I am pasting my code here so that you can understand the problem.
This the code When Search button is pressed.
This is the code for selecting the path for searching.
Here the system throws and exception on the line:
objFolderBrowserDialog.ShowDialog() statement. The exception is thrown from
System.Windows.Forms.dll from the ShowWindow() function. The exception of
System.NullReferenceException. And the main thing is the exception is thrown
only if I start the search in thread. Again, the exception is not thrown on
first attempt. The system allows me to select a path and then start search.
But when I try to select another path for searching system thrown an
exception. Again, the exception is thrown in case of any dialog I try to
open on this page. I tried to open a MessageBox instead of
FolderBrowserDialog just to check but I got the same exception. I also tried
bringing up my custom dialog on this page. I got the same exception.
private void btnPath_Click(object sender, System.EventArgs e)
{
FolderBrowserDialog objFolderBrowserDialog = new FolderBrowserDialog();
objFolderBrowserDialog.Description = "Select Path for selected Computer";
objFolderBrowserDialog.SelectedPath = @"\\" + txtComputer.Text + @"\";
objFolderBrowserDialog.ShowNewFolderButton = false;
if(objFolderBrowserDialog.ShowDialog()== DialogResult.OK)
{
while(true)
{
if(objFolderBrowserDialog.SelectedPath.ToUpper().I ndexOf(txtComputer.Text)
-1)
{
break;
}
else
{
MessageBox.Show("Select path for the computer you have selected","Wrong Path
Selected",MessageBoxButtons.OK,MessageBoxIcon.Info rmation);
objFolderBrowserDialog.SelectedPath = @"\\" + txtComputer.Text + @"\";
objFolderBrowserDialog.ShowDialog();
}
}
txtPath.Text = objFolderBrowserDialog.SelectedPath;
btnSelectMachine.Enabled = false;
btnAdd.Enabled = true;
btnAddNCrawl.Enabled = true;
}
}
private void btnAddNCrawl_Click(object sender, System.EventArgs e)
{
AddScanPathDetails();
// CallBack ChangeStatus = new
CallBack(ILink.Knowledge_Cube.frmStatus.OnChangeSt atus);
// strComputerName = txtComputer.Text;
FileSvcCrawler.FileSvcCrawler objFileSvcCrawler = new
FileSvcCrawler.FileSvcCrawler(txtComputer.Text,int .Parse(nudRescanInt.Value.
ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(objFileSvcCrawler.Crawl);
Thread objThread = new Thread(objThreadStart);
objThread.Name = strComputerName ;
objThread.IsBackground = true;
objThread.Priority = ThreadPriority.Lowest;
objThread.Start();
}
The FileSvcCrawler class is in a separate dll.
I would be very thankful to you if you could give me some hint regarding the
error.
Regards,
Bhavya Shah
"Bhavya Shah" <bh*********@i-link.co.in> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl... Hello,
I am facing a very strange problem in my application.
I have a form on which I select a path. I open the FolderBrowserDialog for
path selection. Once the path is selected I press a button "Search" for
searching documents on that path. This search process runs in a separate
thread so that I can search for multiple paths simultaneously. I face
problem here. After starting the search for one path (that is starting one
thread), when I click on the select folder button to open the
folderbrowserdialog for selecting another path, the application throws and
exception (System.NullReferenceException, Object reference not set to
instance of an object).
I do not get this error if I do not search in thread.
Could anyone tell me the reason for this...I have tried everything but
could not solve the error.
I am pasting my thread starting code here.
FileSvcCrawler is a class which searches the path for documents.
FileSvcCrawler.FileSvcCrawler objFileSvcCrawler = new
FileSvcCrawler.FileSvcCrawler(txtComputer.Text,int .Parse(nudRescanInt.Value. ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(objFileSvcCrawler.Crawl);
Thread objThread = new Thread(objThreadStart);
objThread.Name = strComputerName ;
objThread.IsBackground = true;
objThread.Priority = ThreadPriority.Lowest;
objThread.Start();
Regards,
Bhavya Shah