473,748 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ 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 "SomeFolder s" 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 3429
Sounds like you can only put an exception handle on it.

chanmm

"Brett Romero" <ac*****@cygen. comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.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 "SomeFolder s" 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(Com puterName, 4);

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

These are in System.Net.Netw orkInformation namespace.

Brett

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

chanmm

"Brett Romero" <ac*****@cygen. comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Here's the fix - Ping the machine first:

Ping netMon = new Ping();

PingReply response = netMon.Send(Com puterName, 4);

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

These are in System.Net.Netw orkInformation namespace.

Brett

Nov 18 '06 #5

"Brett Romero" <ac*****@cygen. comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
| Here's the fix - Ping the machine first:
|
| Ping netMon = new Ping();
|
| PingReply response = netMon.Send(Com puterName, 4);
|
| if (response.Addre ss != null)
| networkAccess = true;
| else
| {
| networkAccess = false;
| sb.AppendLine(" Not online");
| }
|
| These are in System.Net.Netw orkInformation 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
9739
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 10:24:48 AM run() error: System.IO.IOException: The specified network password is not correct. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare...
1
2398
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 10:24:48 AM run() error: System.IO.IOException: The specified network password is not correct. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare...
3
7645
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 10:24:48 AM run() error: System.IO.IOException: The specified network password is not correct. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare...
2
3755
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 fileName ......... PictureBox1.Image = Image.FromFile(filePath + fileName)
15
2835
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. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
7
4489
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
1982
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 as a none service program it works fine. I'm assuming that vb programs running as a service do not support network paths. Is that true? Thanks in advance.
3
2239
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 ASP.NET web site map siteMap.Load(HttpContext.Current.Server.MapPath(Me.SiteMapUrl)) Me.SiteMapUrl is a property.
3
4822
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 our server, nothing exotic. I looked at the security permissions and the "write" box for domain users was grey, but not checked. This means read-only to me and sure enough, I cannot change the files. Is there a different way to deal with...
0
1417
by: ColdCoffee | last post by:
Scenario: My computer: name : PrasComp pass : Pras123 Domain : XYZ Computer I wanna access: Name : AnoComp pass : #Pras
0
8994
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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,...
0
9376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9250
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
8247
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...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
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();...
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.