473,466 Members | 4,879 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can't read network path?

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

Nov 16 '06 #1
5 3415
Sounds like you can only put an exception handle on it.

chanmm

"Brett Romero" <ac*****@cygen.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
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

Nov 17 '06 #2

chanmm wrote:
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?

Nov 18 '06 #3
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

Nov 18 '06 #4
Yeap Brett, good idea, really miss this one.

chanmm

"Brett Romero" <ac*****@cygen.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
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

Nov 18 '06 #5

"Brett Romero" <ac*****@cygen.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
| 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
|

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.
Nov 18 '06 #6

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

Similar topics

6
by: moonriver | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004...
1
by: Daniel Xiao | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004...
3
by: Daniel Xiao | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004...
2
by: Duy Vu | last post by:
Hi all, I'm using VB.Net 2003 to write a small program to display images in PictureBox1: Dim filePath As String Dim fileName As String ......... .... Do some stuff to get filePath and...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
7
by: Ronald S. Cook | last post by:
In my .aspx page, I am trying to read file that is on a different on the company network. When I map a drive to it and call from within my .aspx page, I get this error:
2
by: Mike | last post by:
Can a vb program running as a serice not use network paths to do file/io? I can't seem to get my program to work with network paths and files. When I use local disk it works fine. When I run it...
3
by: shapper | last post by:
Hello, In have a class inside a compiled DLL where I have the following code: ' Create site map XML document Dim siteMap As XmlDocument = New XmlDocument ' Load site map XML document from...
3
by: James Maeding | last post by:
I am familiar with using My.Computer.FileSystem.GetDirectoryInfo to get folder attributes, see code below... This does not work though for network drives on my companies system. We use windows as...
0
by: ColdCoffee | last post by:
Scenario: My computer: name : PrasComp pass : Pras123 Domain : XYZ Computer I wanna access: Name : AnoComp pass : #Pras
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.