473,799 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.NullRefe rence 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 FolderBrowserDi alog 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
folderbrowserdi alog for selecting another path, the application throws and
exception (System.NullRef erenceException , 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 objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value .
ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = ThreadPriority. Lowest;

objThread.Start ();

Regards,
Bhavya Shah
Nov 15 '05 #1
4 4223
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.co m

"Bhavya Shah" <bh*********@ i-link.co.in> wrote in message
news:u9******** ********@TK2MSF TNGP10.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 FolderBrowserDi alog 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
folderbrowserdi alog for selecting another path, the application throws and
exception (System.NullRef erenceException , 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 objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value . ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = 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******** ********@TK2MSF TNGP10.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 FolderBrowserDi alog 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
folderbrowserdi alog for selecting another path, the application throws and
exception (System.NullRef erenceException , 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 objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value . ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = 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
FolderBrowserDi alog 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******** ********@TK2MSF TNGP10.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 FolderBrowserDi alog 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
folderbrowserdi alog for selecting another path, the application throws and
exception (System.NullRef erenceException , 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 objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value . ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = 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:

objFolderBrowse rDialog.ShowDia log() statement. The exception is thrown from
System.Windows. Forms.dll from the ShowWindow() function. The exception of
System.NullRefe renceException. 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
FolderBrowserDi alog 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(o bject sender, System.EventArg s e)

{

FolderBrowserDi alog objFolderBrowse rDialog = new FolderBrowserDi alog();

objFolderBrowse rDialog.Descrip tion = "Select Path for selected Computer";

objFolderBrowse rDialog.Selecte dPath = @"\\" + txtComputer.Tex t + @"\";

objFolderBrowse rDialog.ShowNew FolderButton = false;

if(objFolderBro wserDialog.Show Dialog()== DialogResult.OK )

{

while(true)

{

if(objFolderBro wserDialog.Sele ctedPath.ToUppe r().IndexOf(txt Computer.Text)
-1)
{

break;

}

else

{

MessageBox.Show ("Select path for the computer you have selected","Wron g Path
Selected",Messa geBoxButtons.OK ,MessageBoxIcon .Information);

objFolderBrowse rDialog.Selecte dPath = @"\\" + txtComputer.Tex t + @"\";

objFolderBrowse rDialog.ShowDia log();

}

}

txtPath.Text = objFolderBrowse rDialog.Selecte dPath;

btnSelectMachin e.Enabled = false;

btnAdd.Enabled = true;

btnAddNCrawl.En abled = true;

}

}

private void btnAddNCrawl_Cl ick(object sender, System.EventArg s e)

{

AddScanPathDeta ils();

// CallBack ChangeStatus = new
CallBack(ILink. Knowledge_Cube. frmStatus.OnCha ngeStatus);

// strComputerName = txtComputer.Tex t;

FileSvcCrawler. FileSvcCrawler objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value .
ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = 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******** ******@TK2MSFTN GP10.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 FolderBrowserDi alog 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
folderbrowserdi alog for selecting another path, the application throws and
exception (System.NullRef erenceException , 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 objFileSvcCrawl er = new
FileSvcCrawler. FileSvcCrawler( txtComputer.Tex t,int.Parse(nud RescanInt.Value . ToString()), ChangeStatus);
ThreadStart objThreadStart = new ThreadStart(obj FileSvcCrawler. Crawl);

Thread objThread = new Thread(objThrea dStart);

objThread.Name = strComputerName ;

objThread.IsBac kground = true;

objThread.Prior ity = 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
1572
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. The code is the following : <code> using System;
2
1783
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 form. Any ideas on why this might be happening? Please remove 'X's from email address to reply
5
4032
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 is almost impossible to figure out what causes this. I've tried adding: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler (SystemErrorHandler); to my main method, and a handler function:
6
2908
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 there are lot of activities that follow after checking of a perticular component. Thanks
0
1289
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 id="dvConsultantDetails" runat="server" GridLines="none" CssClass="textBlue12" AutoGenerateRows="false" DefaultMode="Edit" OnModeChanging="dvConsultantDetails_ModeChanging" OnItemUpdating="dvConsultantDetails_ItemUpdating"> <Fields>
1
1491
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); in the Cweb Class page the coding is like
4
2081
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 ///my code start here (cs file) using System; using System.Data;
0
1108
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 an OWA web site to override form authentication, with Exchange Server 2007. I keep getting NullReference exception, even though I commented all the code. I then tried to use it in some web site on my 2003 server, and I did manage to run it, and...
2
3003
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 fine in Other PCs .. can someone give solve my Problem? Thanx in Adv Regards ganesh
6
4400
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 restart my application, sometimes several times a day The customer has XP Home SP2
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.