Error : System.IO.IOException: the network path was not found
Asked Answered
A

4

6

when i am executing following code it results an error please help me to resolve this.

 class MySample
{

    public static void Main()
    {


string eventLogName = "Security";

string sourceName = "BTHUSB";

string machineName = "v.i.com";

EventLog eventLog;

eventLog = new EventLog();

eventLog.Log = eventLogName;

eventLog.Source = sourceName;

eventLog.MachineName = machineName;
foreach (EventLogEntry log in eventLog.Entries.Cast<EventLogEntry>().Reverse())// Entries.Cast<EventLogEntry>().Reverse
{
 Console.WriteLine(") Entry type: {0} , Category: {1},  Data: {2}, ID: {3}, Source: {4} \n", log.EntryType, log.TimeWritten, log.EventID, log.InstanceId, log.Source);
}
}
}

Error is ,

  Unhandled Exception: System.IO.IOException: The network path was not found.

  at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode, String str)
  at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive hKey, String ma chineName)
  at System.Diagnostics.EventLog.GetEventLogRegKey(String machine, Boolean writ able)
  at System.Diagnostics.EventLog.Exists(String logName, String machineName)
 at System.Diagnostics.EventLog.OpenForRead(String currentMachineName)
  at System.Diagnostics.EventLog.GetEntryAtNoThrow(Int32 index)
  at System.Diagnostics.EventLogEntryCollection.EntriesEnumerator.MoveNext()
  at System.Linq.Enumerable.<CastIterator>d__aa`1.MoveNext()
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)    at System.Linq.Enumerable.<ReverseIterator>d__99`1.MoveNext()
 at event.MySample.Main() in E:\.net prep\.net examples\event\event\Program.cs :line 42

please help me to resolve this, in a machine name field how to enter the remote machine, when it have v.i.com , but that system name is v only.

Americium answered 8/2, 2013 at 12:17 Comment(1)
have you tried doing it by something like \\MachineName\$E` also is the folder name on that machine really .net examples` can you reach the machine from your machine by \\MachineName\$Drive Path..?Catenary
B
17

If you look at your stack trace you can see the failure happens trying to open the remote registry key.

This means that the Remote Registry service is not running on the target machine. On v.i.com, open the services control panel (services.msc) and start the service called Remote Registry.

This service is normally set to have the startup type of Manual so is not started automatically. If you need to configure or access the event log remotely often, set this to start Automatic so that it's always available.

Bicyclic answered 15/5, 2013 at 19:38 Comment(1)
I got the same error trace, but this fix did not work for me.Indoiranian
C
2

I'd assume the machineName "Venus.InsTIL.com" which you've specified is not contactable via this path. What's the UNC path to the machine? Have you verified the machine is otherwise contactable (ping, UNC file browse etc)?

Charleton answered 8/2, 2013 at 12:23 Comment(0)
E
0

What account is that code running with? It may not have permission to access the network. That will depend on the web service configuration.

Something else is that recent OS versions do not allow strictly local accounts to access administrative shares on other systems, and that will be the account again.

Embezzle answered 8/2, 2013 at 12:23 Comment(2)
the remote host is connected, how can i check it with c# codeAmericium
the server, go to the upload folder. Share it out. Give the identity of your application (if its a web site, use the app pool identity. if the share is on a different machine than the process that needs to get to the share, then you may want to use a domain account for your app pool) permissions for that folder.Embezzle
F
0

It is likely that you did connect to the other machine. I would expect that the error would be more like connection refused or invalid credentials if the connection failed. The fact that this exception is happening on a move next operation (see stack trace) implies that the code was reading through the list when it attempted to read an entry that was not there. My guess is that the entry had been there when the foreach command created its list, but not there when iterating through the list. I suspect the issue is that something is changing the data on you.

Fiberboard answered 2/2, 2018 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.