protected void SaveConfiguredEndpoint(Guid clsid, ConfiguredEndpoint endpoint)
{
try
{
string relativePath = Utils.Format("%CommonApplicationData%\\OPC Foundation\\ComPseudoServers\\{0}.xml", clsid);
string absolutePath = Utils.GetAbsoluteFilePath(relativePath, false, false, true);
// oops - nothing found.
if (absolutePath == null)
{
absolutePath = Utils.GetAbsoluteFilePath(relativePath, true, false, true);
}
// open the file.
FileStream ostrm = File.Open(absolutePath, FileMode.Create, FileAccess.ReadWrite);
using (XmlTextWriter writer = new XmlTextWriter(ostrm, System.Text.Encoding.UTF8))
{
DataContractSerializer serializer = new DataContractSerializer(typeof(ConfiguredEndpoint));
serializer.WriteObject(writer, endpoint);
}
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error saving endpoint configuration for COM Proxy with CLSID={0}.", clsid);
}
}
#endregion