Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Can't read network path?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brett Romero - 16 Nov 2006 00:37 GMT
I'm running the code below to get network paths.

DirectoryInfo diSource = new DirectoryInfo( fullPath );

They usually look like this:

\\cpx-270\SomeFolder

I may or may not have access to SomeFolder.  Sometimes the machine
isn't on or the folder is spelled "SomeFolders" on a particular
machine.  It seems when I run across those scenarios, my app hangs and
I get this error:

LoaderLock was detected
Message: Attempting managed execution inside OS Loader lock. Do not
attempt to run managed code inside a DllMain or image initialization
function since doing so can cause the application to hang.

Any one know how I can avoid this?

Also, it may take a little time to get the network path assigned to
diSource.  I'd like to stall until that variable has a value.  So I
need some type of synchronous contraint before moving on.  Any
suggestions here as well are appreciated.

Thanks,
Brett
chanmm - 17 Nov 2006 09:45 GMT
Sounds like you can only put an exception handle on it.

chanmm

> I'm running the code below to get network paths.
>
[quoted text clipped - 23 lines]
> Thanks,
> Brett
Brett Romero - 18 Nov 2006 00:33 GMT
> Sounds like you can only put an exception handle on it.

Exception handling doesn't really help.  I still have to wait a while
until the exception is thrown.  Is there a way to time out the code
block?
Brett Romero - 18 Nov 2006 01:22 GMT
Here's the fix - Ping the machine first:

Ping netMon = new Ping();

PingReply response = netMon.Send(ComputerName, 4);

if (response.Address != null)
 networkAccess = true;
else
{
 networkAccess = false;
 sb.AppendLine("Not online");
}

These are in System.Net.NetworkInformation namespace.

Brett
chanmm - 18 Nov 2006 03:28 GMT
Yeap Brett, good idea, really miss this one.

chanmm

> Here's the fix - Ping the machine first:
>
[quoted text clipped - 13 lines]
>
> Brett
Willy Denoyette [MVP] - 18 Nov 2006 11:06 GMT
| Here's the fix - Ping the machine first:
|
[quoted text clipped - 13 lines]
|
| Brett

A ping won't help if the server name or share name is mispelled, or if the
"Server" service is not running or if something else is wrong higher up in
the network stack.
Ping only tells you that the remote server's network stack is reachable up
to and including the IP layer. Note also that firewalls and routers may
prevent passing ICMP packets, so ping won't help in such environments
either.

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.