public static DnaLibrary LoadFrom(Uri uri)
{
DnaLibrary dnaLibrary;
XmlSerializer serializer = new DnaLibrarySerializer();
// The uri might be file or http.
try
{
WebRequest req = WebRequest.CreateDefault(uri);
WebResponse res = req.GetResponse();
Stream s = res.GetResponseStream();
dnaLibrary = (DnaLibrary)serializer.Deserialize(s);
}
catch (Exception e)
{
string errorMessage = string.Format("There was an error while loading the .dna file from a Uri:\r\n{0}\r\n{1}\r\nUri:{2}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty, uri.ToString());
Debug.WriteLine(errorMessage);
ExcelDna.Logging.LogDisplay.WriteLine(errorMessage);
return null;
}
dnaLibrary.dnaResolveRoot = null;
return dnaLibrary;
}