By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

RegistryKey.OpenRemoteBaseKey Error

P: n/a
steps..

first, I'm creating a connection by mapping a network drive to the pc
second, the map drive connection was successful I try to read a certian
registry key/value (that is a valid reg item)
third, I disconnect the network drive connection

it works great the first time

but if i run it again on the same pc anytime after that I get the following
error.
the Remote Procedue Call Failed

I have confirmed that the network drive is connecting fine with
administrator priviliges

any ideas
readvalue code below

------------------------------------

/// <summary>
/// To read a registry value.
/// input:
/// output: string of registry value or null
/// </summary>
public string ReadValue(string remoteIP, RegistryHive baseRegistryKey,
string currentSubKey, string currentValueName)
{

RegistryKey rk = null;
RegistryKey sk = null;
string result;

try
{
rk = RegistryKey.OpenRemoteBaseKey(baseRegistryKey, remoteIP);
// when i run this the 2nd time on the same ip
// i get error the Remote Procedue Call Failed
try
{
sk = rk.OpenSubKey(currentSubKey);
try
{
result = sk.GetValue(currentValueName).ToString();
}
catch
{
result = "VALUE NOT FOUND";
}
}
catch
{
result = "KEY NOT FOUND";
}
}
catch(Exception e)
{
result = e.Message.ToString(); //return the error the Remote
Procedue Call Failed
}

return result;

}
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.