473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

System.NullReference exception

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
Nov 15 '05 #1
4 4198
Bhavya,

I can't tell from the code that you provided, but you aren't throwing up
the folder browse dialog in another thread, are you? If so, then that would
be the cause of your problems, as all UI operations should occur on the UI
thread.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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

Nov 15 '05 #2
Hi,

I think that your problem is the select button handler, not in the creation
of the thread which AFAIK should work fine.
Did you try to trace the application, it should give you the line where it
throw the exception.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"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

Nov 15 '05 #3
100
Hi Bhavya,
The code you provided is not enough for us to tell where the problem is. Try
to find out what reference is null. Is it the reference to the
FolderBrowserDialog object or to some other object you use?
If you post the code for select-path button and serarch button event
handlers we may be able to help you out.

B\rgds
100

"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

Nov 15 '05 #4
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

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sergi | last post by:
Hi there, I am getting a System.NullReference exception when calling an unmanaged method CreateClassEnumerator. I am really new to Interop, so that I am having trouble finding out a solution....
2
by: Larry Re | last post by:
I've written a small C# app which appears to work perfectly except for the fact that I get a NullReference exception when I close the form using the red 'X' in the upper right hand corner of the...
5
by: Vitling | last post by:
For no apparent reason, a NullReference exception is thrown in system.dll (System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback). Since I only get a disassembly from Visual Studio, it...
6
by: Arvind | last post by:
Hi, How do u handle this error other than Try Catch method, is there anything like isDBNull() or something on those like so that i can check for the value of the object and take some action as...
0
by: studio60podcast | last post by:
I'm defining the ItemUpdating event for a DetailsView control, but when I try to access the e.NewValues collection, it's throwing a NULLReference exception. Any thoughts? <asp:DetailsView...
1
by: Rama Jayapal | last post by:
i have written the following code to call a method in a class like in the aspx.cs page List<string> surls = new List<string>(); Cweb.GetMainUrls(document,ref surls); Response.Write(surls); ...
4
by: yogarajan | last post by:
hi i had developed pop3 Account mail view in my web page but i got error in (System.NullReference Exception: Object reference not set) NetStrm.Write(szData, 0, szData.Length); - this line ...
0
by: =?Utf-8?B?RGlzcEV2ZW50QWR2aXNlIGZhaWxzIHdpdGggMHg4 | last post by:
Hi, I have a beginner's question and I'm not even sure whether it's an asp question, an Exchange server question or an x64 question... I've been experimenting with HttpModules. I want to use one in...
2
by: ganeshvkl | last post by:
i got error " An unhandled exception of type 'System.NullReferenceException' occurred in system.data.dll " when i run my VB.net 2003 with Sqlserver 2000 server program , the same program is working...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.