Пример #1
0
            public SharedTestState()
            {
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // COM activation is only supported on Windows
                    return;
                }

                ComLibraryFixture = new TestProjectFixture("ComLibrary", RepoDirectories)
                                    .EnsureRestored(RepoDirectories.CorehostPackages)
                                    .BuildProject();

                // Create a .clsidmap from the assembly
                string clsidMapPath = Path.Combine(BaseDirectory, $"{ ComLibraryFixture.TestProject.AssemblyName }.clsidmap");

                using (var assemblyStream = new FileStream(ComLibraryFixture.TestProject.AppDll, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read))
                    using (var peReader = new System.Reflection.PortableExecutable.PEReader(assemblyStream))
                    {
                        if (peReader.HasMetadata)
                        {
                            MetadataReader reader = peReader.GetMetadataReader();
                            ClsidMap.Create(reader, clsidMapPath);
                        }
                    }

                // Use the locally built comhost to create a comhost with the embedded .clsidmap
                ComHostPath = Path.Combine(
                    ComLibraryFixture.TestProject.BuiltApp.Location,
                    $"{ ComLibraryFixture.TestProject.AssemblyName }.comhost.dll");
                ComHost.Create(
                    Path.Combine(RepoDirectories.CorehostPackages, "comhost.dll"),
                    ComHostPath,
                    clsidMapPath);
            }
Пример #2
0
 public void Unload()
 {
     if (ComHost.Configuration.ComSupportActive)
     {
         ComHost.DeactivateClassFactory(typeof(Operations_with_IPS));
     }
 }
Пример #3
0
        public void Load(IServiceProvider serviceProvider)
        {
            if (ComHost.Configuration.ComSupportActive)
            {
                ComHost.ActivateClassFactory(typeof(Operations_with_IPS));
            }

            _serviceProvider = serviceProvider;

            AddMenuItems();
        }
Пример #4
0
            public SharedTestState()
            {
                if (!OperatingSystem.IsWindows())
                {
                    // COM activation is only supported on Windows
                    return;
                }

                ComLibraryFixture = new TestProjectFixture("ComLibrary", RepoDirectories)
                                    .EnsureRestored()
                                    .BuildProject();

                // Create a .clsidmap from the assembly
                ClsidMapPath = Path.Combine(BaseDirectory, $"{ ComLibraryFixture.TestProject.AssemblyName }.clsidmap");
                using (var assemblyStream = new FileStream(ComLibraryFixture.TestProject.AppDll, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read))
                    using (var peReader = new System.Reflection.PortableExecutable.PEReader(assemblyStream))
                    {
                        if (peReader.HasMetadata)
                        {
                            MetadataReader reader = peReader.GetMetadataReader();
                            ClsidMap.Create(reader, ClsidMapPath);
                        }
                    }

                // Use the locally built comhost to create a comhost with the embedded .clsidmap
                ComHostPath = Path.Combine(
                    ComLibraryFixture.TestProject.BuiltApp.Location,
                    $"{ ComLibraryFixture.TestProject.AssemblyName }.comhost.dll");

                // Include the test type libraries in the ComHost tests.
                TypeLibraries = new Dictionary <int, string>
                {
                    { 1, Path.Combine(RepoDirectories.Artifacts, "corehost_test", "Server.tlb") },
                    { 2, Path.Combine(RepoDirectories.Artifacts, "corehost_test", "Nested.tlb") }
                };

                ComHost.Create(
                    Path.Combine(RepoDirectories.HostArtifacts, "comhost.dll"),
                    ComHostPath,
                    ClsidMapPath,
                    TypeLibraries);
            }