internal IViewExtension Load(ViewExtensionDefinition viewExtension) { try { if (viewExtension.IsEnabled) { if (viewExtension.RequiresSignedEntryPoint) { CertificateVerification.CheckAssemblyForValidCertificate(viewExtension.AssemblyPath); } var assembly = Assembly.LoadFrom(viewExtension.AssemblyPath); var result = assembly.CreateInstance(viewExtension.TypeName) as IViewExtension; ExtensionLoading?.Invoke(result); return(result); } return(null); } catch (Exception ex) { var name = viewExtension.TypeName == null ? "null" : viewExtension.TypeName; Log("Could not create an instance of " + name); Log(ex.Message); Log(ex.StackTrace); return(null); } }
private IExtension Load(ExtensionDefinition extension) { try { if (extension.RequiresSignedEntryPoint) { CertificateVerification.CheckAssemblyForValidCertificate(extension.AssemblyPath); } var assembly = Assembly.LoadFrom(extension.AssemblyPath); var result = assembly.CreateInstance(extension.TypeName) as IExtension; ExtensionLoading?.Invoke(result); Logging.Analytics.TrackEvent( Actions.Load, Categories.ExtensionOperations, extension.TypeName); return(result); } catch (Exception ex) { var name = extension.TypeName == null ? "null" : extension.TypeName; Log("Could not create an instance of " + name); Log(ex.Message); Log(ex.StackTrace); return(null); } }
/// <summary> /// Check the node libraries defined in the package json file are valid and have a valid certificate /// </summary> /// <param name="packageDirectoryPath">path to package location</param> /// <param name="discoveredPkg">package object to check</param> private static void CheckPackageNodeLibraryCertificates(string packageDirectoryPath, Package discoveredPkg) { var dllfiles = new System.IO.DirectoryInfo(discoveredPkg.BinaryDirectory).EnumerateFiles("*.dll"); if (discoveredPkg.Header.node_libraries.Count() == 0 && dllfiles.Count() != 0) { throw new LibraryLoadFailedException(packageDirectoryPath, String.Format( Resources.InvalidPackageNoNodeLibrariesDefinedInPackageJson, discoveredPkg.Name, discoveredPkg.RootDirectory)); } foreach (var nodeLibraryAssembly in discoveredPkg.Header.node_libraries) { //Try to get the assembly name from the manifest file string filename; try { filename = new AssemblyName(nodeLibraryAssembly).Name + ".dll"; } catch { throw new LibraryLoadFailedException(packageDirectoryPath, String.Format( Resources.InvalidPackageMalformedNodeLibraryDefinition, discoveredPkg.Name, discoveredPkg.RootDirectory)); } //Verify the node library exists in the package bin directory and has a valid certificate var filepath = Path.Combine(discoveredPkg.BinaryDirectory, filename); try { CertificateVerification.CheckAssemblyForValidCertificate(filepath); } catch (Exception e) { throw new LibraryLoadFailedException(packageDirectoryPath, String.Format( Resources.InvalidPackageNodeLibraryIsNotSigned, discoveredPkg.Name, discoveredPkg.RootDirectory, e.Message)); } } discoveredPkg.RequiresSignedEntryPoints = true; }