Opc.Ua.Com.ComProxy.LoadConfiguredEndpoint C# (CSharp) Method

LoadConfiguredEndpoint() private method

Reads the UA endpoint information associated the CLSID
private LoadConfiguredEndpoint ( System.Guid clsid ) : ConfiguredEndpoint
clsid System.Guid The CLSID used to activate the COM server.
return ConfiguredEndpoint
        private 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.
                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;
            }
        }