ExcelDna.Integration.DnaLibrary.LoadFrom C# (CSharp) Method

LoadFrom() public static method

public static LoadFrom ( Uri uri ) : DnaLibrary
uri System.Uri
return DnaLibrary
        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;
        }

Same methods

DnaLibrary::LoadFrom ( byte bytes, string pathResolveRoot ) : DnaLibrary
DnaLibrary::LoadFrom ( string fileName ) : DnaLibrary