Exemple #1
0
        internal static string[] GetRoleMembers(ComCatalogObject application, ComCatalogCollection rolesCollection)
        {
            ComCatalogCollection collection = application.GetCollection("Roles");
            List <string>        list       = new List <string>();

            ComCatalogCollection.Enumerator enumerator = rolesCollection.GetEnumerator();
            while (enumerator.MoveNext())
            {
                ComCatalogObject current = enumerator.Current;
                string           str     = (string)current.GetValue("Name");
                ComCatalogCollection.Enumerator enumerator2 = collection.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    ComCatalogObject obj3 = enumerator2.Current;
                    string           str2 = (string)obj3.GetValue("Name");
                    if (str == str2)
                    {
                        ComCatalogCollection.Enumerator enumerator3 = obj3.GetCollection("UsersInRole").GetEnumerator();
                        while (enumerator3.MoveNext())
                        {
                            ComCatalogObject obj4 = enumerator3.Current;
                            string           item = (string)obj4.GetValue("User");
                            list.Add(item);
                        }
                        continue;
                    }
                }
            }
            return(list.ToArray());
        }
        public ContractInfo(Guid iid, ServiceEndpointElement endpoint, ComCatalogObject interfaceObject, ComCatalogObject application)
        {
            this.name = endpoint.Contract;
            this.iid  = iid;
            ComCatalogCollection collection = interfaceObject.GetCollection("RolesForInterface");

            this.interfaceRoleMembers = CatalogUtil.GetRoleMembers(application, collection);
            this.operations           = new List <OperationInfo>();
            ComCatalogCollection.Enumerator enumerator = interfaceObject.GetCollection("MethodsForInterface").GetEnumerator();
            while (enumerator.MoveNext())
            {
                ComCatalogObject current = enumerator.Current;
                this.operations.Add(new OperationInfo(current, application));
            }
        }
        public WebHostedComPlusServiceHost(string webhostParams, Uri[] baseAddresses)
        {
            Guid        guid;
            Guid        guid2;
            HostingMode webHostInProcess;

            foreach (Uri uri in baseAddresses)
            {
                base.InternalBaseAddresses.Add(uri);
            }
            string[] strArray = webhostParams.Split(new char[] { ',' });
            if (strArray.Length != 2)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ServiceStringFormatError", new object[] { webhostParams })));
            }
            if (!DiagnosticUtility.Utility.TryCreateGuid(strArray[0], out guid))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ServiceStringFormatError", new object[] { webhostParams })));
            }
            if (!DiagnosticUtility.Utility.TryCreateGuid(strArray[1], out guid2))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ServiceStringFormatError", new object[] { webhostParams })));
            }
            string           str = guid.ToString("B").ToUpperInvariant();
            ComCatalogObject applicationObject = CatalogUtil.FindApplication(guid2);

            if (applicationObject == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ApplicationNotFound", new object[] { guid2.ToString("B").ToUpperInvariant() })));
            }
            ComCatalogCollection collection  = applicationObject.GetCollection("Components");
            ComCatalogObject     classObject = null;

            ComCatalogCollection.Enumerator enumerator = collection.GetEnumerator();
            while (enumerator.MoveNext())
            {
                ComCatalogObject current = enumerator.Current;
                string           str2    = (string)current.GetValue("CLSID");
                if (str.Equals(str2, StringComparison.OrdinalIgnoreCase))
                {
                    classObject = current;
                    break;
                }
            }
            if (classObject == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ClsidNotInApplication", new object[] { str, guid2.ToString("B").ToUpperInvariant() })));
            }
            ServicesSection section = ServicesSection.GetSection();
            ServiceElement  service = null;

            foreach (ServiceElement element2 in section.Services)
            {
                Guid     empty     = Guid.Empty;
                Guid     result    = Guid.Empty;
                string[] strArray2 = element2.Name.Split(new char[] { ',' });
                if ((((strArray2.Length == 2) && DiagnosticUtility.Utility.TryCreateGuid(strArray2[0], out result)) && (DiagnosticUtility.Utility.TryCreateGuid(strArray2[1], out empty) && (empty == guid))) && (result == guid2))
                {
                    service = element2;
                    break;
                }
            }
            if (service == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ClsidNotInConfiguration", new object[] { str })));
            }
            if (((int)applicationObject.GetValue("Activation")) == 0)
            {
                webHostInProcess = HostingMode.WebHostInProcess;
            }
            else
            {
                webHostInProcess = HostingMode.WebHostOutOfProcess;
            }
            base.Initialize(guid, service, applicationObject, classObject, webHostInProcess);
        }
Exemple #4
0
        public void Startup(IProcessInitControl control)
        {
            this.applicationId = ContextUtil.ApplicationId;
            ComPlusDllHostInitializerTrace.Trace(TraceEventType.Information, 0x50008, "TraceCodeComIntegrationDllHostInitializerStarting", this.applicationId);
            Thread thread = null;

            try
            {
                thread = new Thread(new ParameterizedThreadStart(DllHostInitializeWorker.PingProc));
                thread.Start(control);
                ComCatalogObject applicationObject = CatalogUtil.FindApplication(this.applicationId);
                if (applicationObject == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ApplicationNotFound", new object[] { this.applicationId.ToString("B").ToUpperInvariant() })));
                }
                if (((int)applicationObject.GetValue("ConcurrentApps")) > 1)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("PooledApplicationNotSupportedForComplusHostedScenarios", new object[] { this.applicationId.ToString("B").ToUpperInvariant() })));
                }
                if ((((((int)applicationObject.GetValue("RecycleLifetimeLimit")) > 0) || (((int)applicationObject.GetValue("RecycleCallLimit")) > 0)) || (((int)applicationObject.GetValue("RecycleActivationLimit")) > 0)) || (((int)applicationObject.GetValue("RecycleMemoryLimit")) > 0))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("RecycledApplicationNotSupportedForComplusHostedScenarios", new object[] { this.applicationId.ToString("B").ToUpperInvariant() })));
                }
                ComCatalogCollection collection = applicationObject.GetCollection("Components");
                ServicesSection      section    = ServicesSection.GetSection();
                bool flag3 = false;
                foreach (ServiceElement element in section.Services)
                {
                    Guid     empty    = Guid.Empty;
                    Guid     result   = Guid.Empty;
                    string[] strArray = element.Name.Split(new char[] { ',' });
                    if (strArray.Length != 2)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("OnlyClsidsAllowedForServiceType", new object[] { element.Name })));
                    }
                    if (!DiagnosticUtility.Utility.TryCreateGuid(strArray[0], out result))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("OnlyClsidsAllowedForServiceType", new object[] { element.Name })));
                    }
                    if (!DiagnosticUtility.Utility.TryCreateGuid(strArray[1], out empty))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("OnlyClsidsAllowedForServiceType", new object[] { element.Name })));
                    }
                    flag3 = false;
                    ComCatalogCollection.Enumerator enumerator = collection.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        ComCatalogObject current = enumerator.Current;
                        Guid             clsid   = Fx.CreateGuid((string)current.GetValue("CLSID"));
                        if ((clsid == empty) && (this.applicationId == result))
                        {
                            flag3 = true;
                            ComPlusDllHostInitializerTrace.Trace(TraceEventType.Verbose, 0x50009, "TraceCodeComIntegrationDllHostInitializerAddingHost", this.applicationId, clsid, element);
                            this.hosts.Add(new DllHostedComPlusServiceHost(clsid, element, applicationObject, current));
                        }
                    }
                    if (!flag3)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotFindClsidInApplication", new object[] { empty.ToString("B").ToUpperInvariant(), this.applicationId.ToString("B").ToUpperInvariant() })));
                    }
                }
                if (!flag3)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.DllHostInitializerFoundNoServices());
                }
                foreach (ComPlusServiceHost host in this.hosts)
                {
                    host.Open();
                }
            }
            catch (Exception exception)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.ComPlus, (EventLogEventId)(-1073610729), new string[] { this.applicationId.ToString(), exception.ToString() });
                throw;
            }
            finally
            {
                if (thread != null)
                {
                    thread.Abort();
                }
            }
            ComPlusDllHostInitializerTrace.Trace(TraceEventType.Information, 0x5000a, "TraceCodeComIntegrationDllHostInitializerStarted", this.applicationId);
        }
Exemple #5
0
        public ServiceInfo(Guid clsid, System.ServiceModel.Configuration.ServiceElement service, ComCatalogObject application, ComCatalogObject classObject, System.ServiceModel.ComIntegration.HostingMode hostingMode)
        {
            this.service = service;
            this.clsid = clsid;
            this.appid = Fx.CreateGuid((string) application.GetValue("ID"));
            this.partitionId = Fx.CreateGuid((string) application.GetValue("AppPartitionID"));
            this.bitness = (System.ServiceModel.ComIntegration.Bitness) classObject.GetValue("Bitness");
            this.transactionOption = (System.EnterpriseServices.TransactionOption) classObject.GetValue("Transaction");
            this.hostingMode = hostingMode;
            this.managedType = TypeCacheManager.ResolveClsidToType(clsid);
            this.serviceName = application.Name + "." + classObject.Name;
            this.udts = new Dictionary<Guid, List<Type>>();
            COMAdminIsolationLevel level = (COMAdminIsolationLevel) classObject.GetValue("TxIsolationLevel");
            switch (level)
            {
                case COMAdminIsolationLevel.Any:
                    this.isolationLevel = System.Transactions.IsolationLevel.Unspecified;
                    break;

                case COMAdminIsolationLevel.ReadUncommitted:
                    this.isolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
                    break;

                case COMAdminIsolationLevel.ReadCommitted:
                    this.isolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
                    break;

                case COMAdminIsolationLevel.RepeatableRead:
                    this.isolationLevel = System.Transactions.IsolationLevel.RepeatableRead;
                    break;

                case COMAdminIsolationLevel.Serializable:
                    this.isolationLevel = System.Transactions.IsolationLevel.Serializable;
                    break;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidIsolationLevelValue", new object[] { this.clsid, level })));
            }
            switch (((COMAdminThreadingModel) classObject.GetValue("ThreadingModel")))
            {
                case COMAdminThreadingModel.Apartment:
                case COMAdminThreadingModel.Main:
                    this.threadingModel = System.ServiceModel.ComIntegration.ThreadingModel.STA;
                    this.objectPoolingEnabled = false;
                    break;

                default:
                    this.threadingModel = System.ServiceModel.ComIntegration.ThreadingModel.MTA;
                    this.objectPoolingEnabled = (bool) classObject.GetValue("ObjectPoolingEnabled");
                    break;
            }
            if (this.objectPoolingEnabled)
            {
                this.maxPoolSize = (int) classObject.GetValue("MaxPoolSize");
            }
            else
            {
                this.maxPoolSize = 0;
            }
            if (((bool) application.GetValue("ApplicationAccessChecksEnabled")) && ((bool) classObject.GetValue("ComponentAccessChecksEnabled")))
            {
                this.checkRoles = true;
            }
            ComCatalogCollection collection = classObject.GetCollection("RolesForComponent");
            this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, collection);
            this.contracts = new List<ContractInfo>();
            ComCatalogCollection catalogs2 = classObject.GetCollection("InterfacesForComponent");
            foreach (ServiceEndpointElement element in service.Endpoints)
            {
                ContractInfo item = null;
                if (element.Contract != "IMetadataExchange")
                {
                    Guid guid;
                    if (DiagnosticUtility.Utility.TryCreateGuid(element.Contract, out guid))
                    {
                        bool flag3 = false;
                        foreach (ContractInfo info2 in this.contracts)
                        {
                            if (guid == info2.IID)
                            {
                                flag3 = true;
                                break;
                            }
                        }
                        if (flag3)
                        {
                            continue;
                        }
                        ComCatalogCollection.Enumerator enumerator = catalogs2.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            Guid guid2;
                            ComCatalogObject current = enumerator.Current;
                            if (DiagnosticUtility.Utility.TryCreateGuid((string) current.GetValue("IID"), out guid2) && (guid2 == guid))
                            {
                                item = new ContractInfo(guid, element, current, application);
                                break;
                            }
                        }
                    }
                    if (item == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("EndpointNotAnIID", new object[] { clsid.ToString("B").ToUpperInvariant(), element.Contract })));
                    }
                    this.contracts.Add(item);
                }
            }
        }