예제 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <exception cref="FileNotFoundException"></exception>
 /// <exception cref="GacException"></exception>
 /// <param name="otherAppExe"></param>
 /// <param name="sharedAssemblies"></param>
 public GacManager(string otherAppExe, IEnumerable<string> sharedAssemblies)
 {
   _gacSyncRoot = new object();
   _otherAppExe = new ApplicationFile(otherAppExe);
   if (_otherAppExe.Type != FileType.Executable)
     throw new GacException("\"" + _otherAppExe.FileName + "\" is no valid executable.");
   _sharedAssemblies = new List<ApplicationFile>();
   foreach (var sharedAssembly in sharedAssemblies)
   {
     var file = new ApplicationFile(sharedAssembly);
     if (file.Type == FileType.Library)
       _sharedAssemblies.Add(file);
   }
 }
 /// <summary>
 /// Initializes a new instance of <see cref="ProcessSynchronizer"/>.
 /// The constructor will create default databases from the specified files.
 /// </summary>
 /// <param name="fileSystemRoot">The directory to use as root of the file system.</param>
 /// <param name="fileSystemRuleCollection">The collection of engine rules to apply on the file system virtualization engine.</param>
 /// <param name="registryDatabaseFile">The file to use with a default <see cref="RegistryDatabase"/>.</param>
 /// <param name="registryRuleCollection">The collection of engine rules to apply on the registry virtualization engine.</param>
 public ProcessSynchronizer(ApplicationFile fileSystemRoot, FileSystemRuleCollection fileSystemRuleCollection,
   ApplicationFile registryDatabaseFile, RegistryRuleCollection registryRuleCollection)
 {
   if (fileSystemRoot.Type != FileType.Directory)
     throw new ArgumentException("The root location specified for the file system is not valid.", "fileSystemRoot");
   if (registryDatabaseFile.Type != FileType.Database)
     throw new ArgumentException("The filename specified for the registry database is not valid.", "registryDatabaseFile");
   _connectionStrings = new Dictionary<ConfigurationDataType, string>(2)
                          {
                            {ConfigurationDataType.RegistryDatabaseFile, registryDatabaseFile.FileName},
                            {ConfigurationDataType.FileSystemRoot, fileSystemRoot.FileName}
                          };
   _fsRuleCollection = fileSystemRuleCollection;
   _regRuleCollection = registryRuleCollection;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="Packager"/>.
 /// </summary>
 /// <param name="applicationData">The data to base the packaging process on.</param>
 /// <param name="outputFolder">The location where the application must be packaged to.</param>
 public Packager(ApplicationData applicationData, string outputFolder)
 {
   var workingDirectory = new ApplicationFile(outputFolder);
   if (workingDirectory.Type != FileType.Directory)
     throw new ArgumentException("The value specified for the outputFolder is invalid.", "outputFolder");
   _startInfo = new VirtualProcessStartInfo(applicationData, workingDirectory);
   _waitHandle = new AutoResetEvent(false);
 }
예제 #4
0
 /// <summary>
 /// Starts a process from the <see cref="ApplicationData"/> loaded from the filename specified.
 /// </summary>
 /// <exception cref="FileNotFoundException">
 /// A <see cref="FileNotFoundException"/> is thrown if the <paramref name="applicationDataFile"/> can not be found.
 /// </exception>
 /// <exception cref="HostException">
 /// A <see cref="HostException"/> is thrown if the process can't be started.
 /// </exception>
 /// <param name="applicationDataFile">
 /// The file to load the <see cref="ApplicationData"/> from,
 /// representing the application to start.
 /// </param>
 public static void StartProcess(string applicationDataFile)
 {
   if (!File.Exists(applicationDataFile))
     throw new FileNotFoundException("Unable to locate the virtual application's datafile.", applicationDataFile);
   var data = ApplicationData.Load(applicationDataFile);
   if (data == null)
     throw new HostException("\"" + applicationDataFile + "\""
                             + " could not be found or contains invalid data while trying"
                             + " to start a new process based on this file.");
   var workingDirectory = new ApplicationFile(Path.GetDirectoryName(applicationDataFile));
   var startInfo = new VirtualProcessStartInfo(data, workingDirectory);
   _process = VirtualizedProcess.Start(startInfo);
 }
 /// <summary>
 /// Initializes a new instance of <see cref="VirtualProcessStartInfo"/>
 ///  based on the <see cref="ApplicationData"/> specified.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// An <see cref="ArgumentNullException"/> is thrown if <paramref name="data"/> of one of its properties is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// An <see cref="ArgumentException"/> is thrown if any of the properties of <paramref name="data"/> is of the wrong type.
 /// </exception>
 /// <param name="data">The data to base the process on.</param>
 /// <param name="workingDirectory">The working directory of the process to start.</param>
 public VirtualProcessStartInfo(ApplicationData data, ApplicationFile workingDirectory)
 {
   if (data == null
       || data.Files.RegistryDatabase == null
       || data.Files.Executable == null
       || data.Files.RootDirectory == null)
     throw new ArgumentNullException("data", "The data argument or one of its properties is null.");
   if (workingDirectory == null)
     throw new ArgumentNullException("workingDirectory", "The workingDirectory argument is null.");
   if (data.Files.Executable.Type != FileType.Executable)
     throw new ArgumentException("The ApplicationData specified contains an illegal value for the main executable.",
                                 "data");
   if (data.Files.RegistryDatabase.Type != FileType.Database)
     throw new ArgumentException(
       "The ApplicationData specified contains an illegal value for the registry database.",
       "data");
   if (workingDirectory.Type != FileType.Directory)
     throw new ArgumentException("The working directory specified is not a directory.",
                                 "workingDirectory");
   _files = new ApplicationFiles
              {
                RegistryDatabase
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RegistryDatabase.FileName)),
                Executable
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.Executable.FileName)),
                RootDirectory
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RootDirectory.FileName))
              };
   _arguments = "";
   _workingDirectory = workingDirectory;
   _fileSystemRuleCollection = data.Settings.FileSystemEngineRuleCollection ?? FileSystemRuleCollection.GetDefaultRuleCollection();
   _registryRuleCollection = data.Settings.RegistryEngineRuleCollection ?? RegistryRuleCollection.GetDefaultRuleCollection();
 }