protected ConfiguredEndpoint LoadConfiguredEndpoint(Guid clsid)
{
try
{
string relativePath = Utils.Format("%CommonApplicationData%\\OPC Foundation\\ComPseudoServers\\{0}.xml", clsid);
string absolutePath = Utils.GetAbsoluteFilePath(relativePath, false, false, false);
// oops - nothing found.
if (absolutePath == null)
{
return null;
}
// open the file.
using (FileStream istrm = File.Open(absolutePath, FileMode.Open, FileAccess.Read))
{
using (XmlTextReader reader = new XmlTextReader(istrm))
{
DataContractSerializer serializer = new DataContractSerializer(typeof(ConfiguredEndpoint));
return (ConfiguredEndpoint)serializer.ReadObject(reader, false);
}
}
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error loading endpoint configuration for COM Proxy with CLSID={0}.", clsid);
return null;
}
}