public static ActivationContextActivator FromExternalManifest(string source, string assemblyDirectory)
 {
     ActivationContextActivator.ACTCTX actctx = default(ActivationContextActivator.ACTCTX);
     actctx.cbSize              = Marshal.SizeOf(actctx);
     actctx.lpSource            = source;
     actctx.lpAssemblyDirectory = assemblyDirectory;
     actctx.dwFlags             = 36U;
     return(ActivationContextActivator.FromActivationContext(actctx));
 }
        private ActivationContextActivator(ActivationContextActivator.ACTCTX actctx)
        {
            this.m_hActivationContext = ActivationContextActivator.CreateActCtx(ref actctx);

            if (this.m_hActivationContext.IsInvalid || !ActivationContextActivator.ActivateActCtx(this.m_hActivationContext, out this.m_cookie))
            {
                throw new ActivationContextActivatorException();
            }
        }
        internal static void ValidateRulePackage(XDocument rulePackXDoc, string rulePackContents)
        {
            string mceExecutablePath = ClassificationDefinitionUtils.GetMceExecutablePath(true);

            if (mceExecutablePath == null || !File.Exists(mceExecutablePath))
            {
                throw new COMException("Unable to locate the Microsoft Classification Engine", -2147287038);
            }
            try
            {
                using (ActivationContextActivator.FromInternalManifest(mceExecutablePath, Path.GetDirectoryName(mceExecutablePath)))
                {
                    MicrosoftClassificationEngine microsoftClassificationEngine = new MicrosoftClassificationEngine();
                    PropertyBag       propertyBag       = new PropertyBag();
                    RulePackageLoader rulePackageLoader = new RulePackageLoader();
                    microsoftClassificationEngine.Init(propertyBag, rulePackageLoader);
                    RULE_PACKAGE_DETAILS rule_PACKAGE_DETAILS = default(RULE_PACKAGE_DETAILS);
                    rule_PACKAGE_DETAILS.RulePackageSetID = "not-used-here";
                    rule_PACKAGE_DETAILS.RulePackageID    = "test-rule-pack";
                    rule_PACKAGE_DETAILS.RuleIDs          = null;
                    RULE_PACKAGE_DETAILS rule_PACKAGE_DETAILS2 = rule_PACKAGE_DETAILS;
                    rulePackageLoader.SetRulePackage(rule_PACKAGE_DETAILS2.RulePackageID, rulePackContents);
                    try
                    {
                        MicrosoftClassificationEngine microsoftClassificationEngine2 = microsoftClassificationEngine;
                        RULE_PACKAGE_DETAILS          rule_PACKAGE_DETAILS3          = rule_PACKAGE_DETAILS2;
                        microsoftClassificationEngine2.GetClassificationDefinitions(ref rule_PACKAGE_DETAILS3);
                    }
                    catch (COMException ex)
                    {
                        if (ex.ErrorCode == -2147220978)
                        {
                            List <string> value = ClassificationEngineValidator.GetInvalidRegexes(microsoftClassificationEngine, rulePackageLoader, rulePackXDoc).ToList <string>();
                            ex.Data[ClassificationEngineValidator.BadRegexesKey] = value;
                        }
                        throw ex;
                    }
                }
            }
            catch (ActivationContextActivatorException)
            {
                throw new COMException("Unable to instantiate the Microsoft Classification Engine", -2147164127);
            }
        }
示例#4
0
        protected override void InternalProcessRecord()
        {
            string mceExecutablePath = ClassificationDefinitionUtils.GetMceExecutablePath(true);

            if (mceExecutablePath == null || !File.Exists(mceExecutablePath))
            {
                throw new ErrorCannotLoadFingerprintCreatorException();
            }
            try
            {
                using (ActivationContextActivator.FromInternalManifest(mceExecutablePath, Path.GetDirectoryName(mceExecutablePath)))
                {
                    MicrosoftFingerprintCreator microsoftFingerprintCreator = new MicrosoftFingerprintCreator();
                    try
                    {
                        base.WriteVerbose(Strings.VerboseBeginFingerprint);
                        byte[] bytes;
                        uint   base64EncodedFingerprint = microsoftFingerprintCreator.GetBase64EncodedFingerprint(this.extractedText, ref bytes);
                        base.WriteVerbose(Strings.VerboseEndFingerprint);
                        this.extractedText = string.Empty;
                        base.WriteObject(new Fingerprint(Encoding.ASCII.GetString(bytes), base64EncodedFingerprint, this.Description));
                    }
                    catch (COMException innerException)
                    {
                        throw new ErrorCannotCreateFingerprintException(innerException);
                    }
                    catch (ArgumentException innerException2)
                    {
                        throw new ErrorCannotCreateFingerprintException(innerException2);
                    }
                }
            }
            catch (ActivationContextActivatorException innerException3)
            {
                throw new ErrorCannotCreateFingerprintException(innerException3);
            }
        }
 protected override bool ReleaseHandle()
 {
     return(ActivationContextActivator.DeactivateActCtx(0, this.handle));
 }
 protected override bool ReleaseHandle()
 {
     ActivationContextActivator.ReleaseActCtx(this.handle);
     return(true);
 }