protected void VerifyFunctionality()
 {
     object obj2 = new CServiceConfig();
     if (!(obj2 is IServiceSysTxnConfig))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.QFENotPresent());
     }
 }
        protected void VerifyFunctionality()
        {
            object obj2 = new CServiceConfig();

            if (!(obj2 is IServiceSysTxnConfig))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.QFENotPresent());
            }
        }
Example #3
0
        protected void VerifyFunctionality()
        {
            object serviceConfig = new CServiceConfig();
            IServiceSysTxnConfig sysTxnconfing = serviceConfig as IServiceSysTxnConfig;

            if (sysTxnconfing == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.QFENotPresent());
            }
        }
        object SetupServiceConfig(InstanceContext instanceContext, Message message)
        {
            object serviceConfig = new CServiceConfig();

            // Threading
            //
            IServiceThreadPoolConfig threadPoolConfig;

            threadPoolConfig = (IServiceThreadPoolConfig)(serviceConfig);
            switch (this.info.ThreadingModel)
            {
            case ThreadingModel.MTA:
                threadPoolConfig.SelectThreadPool(ThreadPoolOption.MTA);
                break;

            case ThreadingModel.STA:
                threadPoolConfig.SelectThreadPool(ThreadPoolOption.STA);
                break;

            default:
                Fx.Assert("Unexpected threading model");

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.UnexpectedThreadingModel());
            }
            threadPoolConfig.SetBindingInfo(BindingOption.BindingToPoolThread);

            // SxS activation context properties
            //


            // Manifest for VARIANT UDT types
            //

            // this only gets executed if we actually have UDTs
            if (this.info.HasUdts())
            {
                IServiceSxsConfig sxsConfig = serviceConfig as IServiceSxsConfig;
                if (sxsConfig == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.QFENotPresent());
                }

                lock (manifestLock)
                {
                    string tempPath = String.Empty;

                    try
                    {
                        tempPath = Path.GetTempPath();
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.CannotAccessDirectory(tempPath));
                    }

                    string manifestDirectory = tempPath + this.info.AppID.ToString() + @"\";


                    if (!Directory.Exists(manifestDirectory))
                    {
                        try
                        {
                            Directory.CreateDirectory(manifestDirectory);
                        }
                        catch (Exception e)
                        {
                            if (Fx.IsFatal(e))
                            {
                                throw;
                            }

                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.CannotAccessDirectory(manifestDirectory));
                        }

                        Guid[] assemblyGuids = this.info.Assemblies;
                        ComIntegrationManifestGenerator.GenerateManifestCollectionFile(assemblyGuids, manifestDirectory + manifestFileName + @".manifest", manifestFileName);

                        foreach (Guid g in assemblyGuids)
                        {
                            Type[] types = this.info.GetTypes(g);
                            if (types.Length > 0)
                            {
                                String guidStr = g.ToString();
                                ComIntegrationManifestGenerator.GenerateWin32ManifestFile(types, manifestDirectory + guidStr + @".manifest", guidStr);
                            }
                        }
                    }


                    sxsConfig.SxsConfig(CSC_SxsConfig.CSC_NewSxs);
                    sxsConfig.SxsName(manifestFileName + @".manifest");
                    sxsConfig.SxsDirectory(manifestDirectory);
                }
            }


            // Partitions
            //
            if (this.info.PartitionId != DefaultPartitionId)
            {
                IServicePartitionConfig partitionConfig;
                partitionConfig = (IServicePartitionConfig)(serviceConfig);
                partitionConfig.PartitionConfig(PartitionOption.New);
                partitionConfig.PartitionID(this.info.PartitionId);
            }

            // Transactions
            //
            IServiceTransactionConfig transactionConfig;

            transactionConfig = (IServiceTransactionConfig)(serviceConfig);
            transactionConfig.ConfigureTransaction(
                TransactionConfig.NoTransaction);

            if ((this.info.TransactionOption == TransactionOption.Required) ||
                (this.info.TransactionOption == TransactionOption.Supported))
            {
                Transaction messageTransaction = null;
                messageTransaction = MessageUtil.GetMessageTransaction(message);
                if (messageTransaction != null)
                {
                    TransactionProxy proxy = new TransactionProxy(info.AppID, info.Clsid);
                    proxy.SetTransaction(messageTransaction);

                    instanceContext.Extensions.Add(proxy);
                    IServiceSysTxnConfig sysTxnconfing = (IServiceSysTxnConfig)transactionConfig;
                    IntPtr pUnk = TransactionProxyBuilder.CreateTransactionProxyTearOff(proxy);
                    sysTxnconfing.ConfigureBYOTSysTxn(pUnk);
                    Marshal.Release(pUnk);
                }
            }
            return(serviceConfig);
        }
        private object SetupServiceConfig(InstanceContext instanceContext, Message message)
        {
            object obj2 = new CServiceConfig();
            IServiceThreadPoolConfig config = (IServiceThreadPoolConfig) obj2;
            switch (this.info.ThreadingModel)
            {
                case ThreadingModel.MTA:
                    config.SelectThreadPool(System.ServiceModel.ComIntegration.ThreadPoolOption.MTA);
                    break;

                case ThreadingModel.STA:
                    config.SelectThreadPool(System.ServiceModel.ComIntegration.ThreadPoolOption.STA);
                    break;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.UnexpectedThreadingModel());
            }
            config.SetBindingInfo(System.ServiceModel.ComIntegration.BindingOption.BindingToPoolThread);
            if (this.info.HasUdts())
            {
                IServiceSxsConfig config2 = obj2 as IServiceSxsConfig;
                if (config2 == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.QFENotPresent());
                }
                lock (manifestLock)
                {
                    string directory = string.Empty;
                    try
                    {
                        directory = Path.GetTempPath();
                    }
                    catch (Exception exception)
                    {
                        if (Fx.IsFatal(exception))
                        {
                            throw;
                        }
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.CannotAccessDirectory(directory));
                    }
                    string path = directory + this.info.AppID.ToString() + @"\";
                    if (!Directory.Exists(path))
                    {
                        try
                        {
                            Directory.CreateDirectory(path);
                        }
                        catch (Exception exception2)
                        {
                            if (Fx.IsFatal(exception2))
                            {
                                throw;
                            }
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.CannotAccessDirectory(path));
                        }
                        Guid[] assemblies = this.info.Assemblies;
                        ComIntegrationManifestGenerator.GenerateManifestCollectionFile(assemblies, path + manifestFileName + ".manifest", manifestFileName);
                        foreach (Guid guid in assemblies)
                        {
                            System.Type[] types = this.info.GetTypes(guid);
                            if (types.Length > 0)
                            {
                                string assemblyName = guid.ToString();
                                ComIntegrationManifestGenerator.GenerateWin32ManifestFile(types, path + assemblyName + ".manifest", assemblyName);
                            }
                        }
                    }
                    config2.SxsConfig(CSC_SxsConfig.CSC_NewSxs);
                    config2.SxsName(manifestFileName + ".manifest");
                    config2.SxsDirectory(path);
                }
            }
            if (this.info.PartitionId != DefaultPartitionId)
            {
                IServicePartitionConfig config3 = (IServicePartitionConfig) obj2;
                config3.PartitionConfig(System.ServiceModel.ComIntegration.PartitionOption.New);
                config3.PartitionID(this.info.PartitionId);
            }
            IServiceTransactionConfig config4 = (IServiceTransactionConfig) obj2;
            config4.ConfigureTransaction(TransactionConfig.NoTransaction);
            if ((this.info.TransactionOption == TransactionOption.Required) || (this.info.TransactionOption == TransactionOption.Supported))
            {
                Transaction messageTransaction = null;
                messageTransaction = MessageUtil.GetMessageTransaction(message);
                if (messageTransaction != null)
                {
                    System.ServiceModel.ComIntegration.TransactionProxy item = new System.ServiceModel.ComIntegration.TransactionProxy(this.info.AppID, this.info.Clsid);
                    item.SetTransaction(messageTransaction);
                    instanceContext.Extensions.Add(item);
                    IServiceSysTxnConfig config5 = (IServiceSysTxnConfig) config4;
                    IntPtr pITxByot = TransactionProxyBuilder.CreateTransactionProxyTearOff(item);
                    config5.ConfigureBYOTSysTxn(pITxByot);
                    Marshal.Release(pITxByot);
                }
            }
            return obj2;
        }
        object SetupServiceConfig(InstanceContext instanceContext, Message message)
        {
            object serviceConfig = new CServiceConfig();

            // Threading
            //
            IServiceThreadPoolConfig threadPoolConfig;
            threadPoolConfig = (IServiceThreadPoolConfig)(serviceConfig);
            switch (this.info.ThreadingModel)
            {
                case ThreadingModel.MTA:
                    threadPoolConfig.SelectThreadPool(ThreadPoolOption.MTA);
                    break;

                case ThreadingModel.STA:
                    threadPoolConfig.SelectThreadPool(ThreadPoolOption.STA);
                    break;

                default:
                    Fx.Assert("Unexpected threading model");

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.UnexpectedThreadingModel());
            }
            threadPoolConfig.SetBindingInfo(BindingOption.BindingToPoolThread);

            // SxS activation context properties
            //                   


            // Manifest for VARIANT UDT types
            //

            // this only gets executed if we actually have UDTs
            if (this.info.HasUdts())
            {
                IServiceSxsConfig sxsConfig = serviceConfig as IServiceSxsConfig;
                if (sxsConfig == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.QFENotPresent());
                }

                lock (manifestLock)
                {
                    string tempPath = String.Empty;

                    try
                    {
                        tempPath = Path.GetTempPath();
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                            throw;

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.CannotAccessDirectory(tempPath));
                    }

                    string manifestDirectory = tempPath + this.info.AppID.ToString() + @"\";


                    if (!Directory.Exists(manifestDirectory))
                    {
                        try
                        {
                            Directory.CreateDirectory(manifestDirectory);
                        }
                        catch (Exception e)
                        {
                            if (Fx.IsFatal(e))
                                throw;

                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.CannotAccessDirectory(manifestDirectory));
                        }

                        Guid[] assemblyGuids = this.info.Assemblies;
                        ComIntegrationManifestGenerator.GenerateManifestCollectionFile(assemblyGuids, manifestDirectory + manifestFileName + @".manifest", manifestFileName);

                        foreach (Guid g in assemblyGuids)
                        {
                            Type[] types = this.info.GetTypes(g);
                            if (types.Length > 0)
                            {
                                String guidStr = g.ToString();
                                ComIntegrationManifestGenerator.GenerateWin32ManifestFile(types, manifestDirectory + guidStr + @".manifest", guidStr);
                            }
                        }
                    }


                    sxsConfig.SxsConfig(CSC_SxsConfig.CSC_NewSxs);
                    sxsConfig.SxsName(manifestFileName + @".manifest");
                    sxsConfig.SxsDirectory(manifestDirectory);
                }
            }


            // Partitions
            //
            if (this.info.PartitionId != DefaultPartitionId)
            {
                IServicePartitionConfig partitionConfig;
                partitionConfig = (IServicePartitionConfig)(serviceConfig);
                partitionConfig.PartitionConfig(PartitionOption.New);
                partitionConfig.PartitionID(this.info.PartitionId);
            }

            // Transactions
            //
            IServiceTransactionConfig transactionConfig;
            transactionConfig = (IServiceTransactionConfig)(serviceConfig);
            transactionConfig.ConfigureTransaction(
                TransactionConfig.NoTransaction);

            if ((this.info.TransactionOption == TransactionOption.Required) ||
                (this.info.TransactionOption == TransactionOption.Supported))
            {
                Transaction messageTransaction = null;
                messageTransaction = MessageUtil.GetMessageTransaction(message);
                if (messageTransaction != null)
                {
                    TransactionProxy proxy = new TransactionProxy(info.AppID, info.Clsid);
                    proxy.SetTransaction(messageTransaction);

                    instanceContext.Extensions.Add(proxy);
                    IServiceSysTxnConfig sysTxnconfing = (IServiceSysTxnConfig)transactionConfig;
                    IntPtr pUnk = TransactionProxyBuilder.CreateTransactionProxyTearOff(proxy);
                    sysTxnconfing.ConfigureBYOTSysTxn(pUnk);
                    Marshal.Release(pUnk);
                }
            }
            return serviceConfig;
        }
Example #7
0
        public static int Main(string[] args)
        {
            // make sure the text output displays properly on various languages
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();
            if ((System.Console.OutputEncoding.CodePage != 65001) &&
                 (System.Console.OutputEncoding.CodePage !=
                  Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            }

            object serviceConfig = new CServiceConfig();
            IServiceSysTxnConfig sysTxnconfing = serviceConfig as IServiceSysTxnConfig;
            if (sysTxnconfing == null)
            {
                ToolConsole.WriteError(SR.GetString(SR.WindowsFunctionalityMissing), "");
                return 1;
            }
            if ((Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 1))
            {
                if (!CheckForCorrectOle32())
                {
                    ToolConsole.WriteError(SR.GetString(SR.WindowsFunctionalityMissing), "");
                    return 1;
                }
            }
            try
            {
                EnsureUserIsAdministrator();
                Tool.options = Options.ParseArguments(args);
                ToolConsole.Verbose = options.Verbose;

                Run();
            }
            catch (ArgumentException ae)
            {
                ToolConsole.WriteError(ae);
                Console.WriteLine(SR.GetString(SR.MoreHelp, Abbr.Help));
                return 1;
            }
            catch (ApplicationException appException)
            {
                ToolConsole.WriteError(appException);
                return 1;
            }
            catch (Exception e)
            {
                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
                ToolConsole.WriteDetailedException(e, SR.GetString(SR.UnExpectedError));
                return 1;
            }
            return 0;
        }
        private object SetupServiceConfig(InstanceContext instanceContext, Message message)
        {
            object obj2 = new CServiceConfig();
            IServiceThreadPoolConfig config = (IServiceThreadPoolConfig)obj2;

            switch (this.info.ThreadingModel)
            {
            case ThreadingModel.MTA:
                config.SelectThreadPool(System.ServiceModel.ComIntegration.ThreadPoolOption.MTA);
                break;

            case ThreadingModel.STA:
                config.SelectThreadPool(System.ServiceModel.ComIntegration.ThreadPoolOption.STA);
                break;

            default:
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.UnexpectedThreadingModel());
            }
            config.SetBindingInfo(System.ServiceModel.ComIntegration.BindingOption.BindingToPoolThread);
            if (this.info.HasUdts())
            {
                IServiceSxsConfig config2 = obj2 as IServiceSxsConfig;
                if (config2 == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.QFENotPresent());
                }
                lock (manifestLock)
                {
                    string directory = string.Empty;
                    try
                    {
                        directory = Path.GetTempPath();
                    }
                    catch (Exception exception)
                    {
                        if (Fx.IsFatal(exception))
                        {
                            throw;
                        }
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.CannotAccessDirectory(directory));
                    }
                    string path = directory + this.info.AppID.ToString() + @"\";
                    if (!Directory.Exists(path))
                    {
                        try
                        {
                            Directory.CreateDirectory(path);
                        }
                        catch (Exception exception2)
                        {
                            if (Fx.IsFatal(exception2))
                            {
                                throw;
                            }
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.CannotAccessDirectory(path));
                        }
                        Guid[] assemblies = this.info.Assemblies;
                        ComIntegrationManifestGenerator.GenerateManifestCollectionFile(assemblies, path + manifestFileName + ".manifest", manifestFileName);
                        foreach (Guid guid in assemblies)
                        {
                            System.Type[] types = this.info.GetTypes(guid);
                            if (types.Length > 0)
                            {
                                string assemblyName = guid.ToString();
                                ComIntegrationManifestGenerator.GenerateWin32ManifestFile(types, path + assemblyName + ".manifest", assemblyName);
                            }
                        }
                    }
                    config2.SxsConfig(CSC_SxsConfig.CSC_NewSxs);
                    config2.SxsName(manifestFileName + ".manifest");
                    config2.SxsDirectory(path);
                }
            }
            if (this.info.PartitionId != DefaultPartitionId)
            {
                IServicePartitionConfig config3 = (IServicePartitionConfig)obj2;
                config3.PartitionConfig(System.ServiceModel.ComIntegration.PartitionOption.New);
                config3.PartitionID(this.info.PartitionId);
            }
            IServiceTransactionConfig config4 = (IServiceTransactionConfig)obj2;

            config4.ConfigureTransaction(TransactionConfig.NoTransaction);
            if ((this.info.TransactionOption == TransactionOption.Required) || (this.info.TransactionOption == TransactionOption.Supported))
            {
                Transaction messageTransaction = null;
                messageTransaction = MessageUtil.GetMessageTransaction(message);
                if (messageTransaction != null)
                {
                    System.ServiceModel.ComIntegration.TransactionProxy item = new System.ServiceModel.ComIntegration.TransactionProxy(this.info.AppID, this.info.Clsid);
                    item.SetTransaction(messageTransaction);
                    instanceContext.Extensions.Add(item);
                    IServiceSysTxnConfig config5 = (IServiceSysTxnConfig)config4;
                    IntPtr pITxByot = TransactionProxyBuilder.CreateTransactionProxyTearOff(item);
                    config5.ConfigureBYOTSysTxn(pITxByot);
                    Marshal.Release(pITxByot);
                }
            }
            return(obj2);
        }
 protected void VerifyFunctionality()
 {
     object serviceConfig = new CServiceConfig();
     IServiceSysTxnConfig sysTxnconfing = serviceConfig as IServiceSysTxnConfig;
     if (sysTxnconfing == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.QFENotPresent());
     }
 }