public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusServiceHostSchema record = new ComPlusServiceHostSchema(info.AppID, info.Clsid);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ContractDescription contract, Binding binding, string address)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusMexChannelBuilderSchema record = new ComPlusMexChannelBuilderSchema(contract.Name, contract.Namespace, binding.Name, binding.Namespace, address);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Guid appid, Guid clsid, Guid transactionID, int instanceID)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusTxProxySchema record = new ComPlusTxProxySchema(appid, clsid, transactionID, instanceID);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Uri address, Type contractType)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusChannelCreatedSchema record = new ComPlusChannelCreatedSchema(address, (contractType != null) ? contractType.ToString() : null);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Guid iid, Guid typeLibraryID, string assembly)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusTLBImportFromAssemblySchema record =
             new ComPlusTLBImportFromAssemblySchema(iid, typeLibraryID, assembly);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Guid appid)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusDllHostInitializerSchema record =
             new ComPlusDllHostInitializerSchema(appid);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, InstanceContext instanceContext, int instanceID)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusInstanceReleasedSchema record =
             new ComPlusInstanceReleasedSchema(info.AppID, info.Clsid, instanceID);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Guid iid, Guid typeLibraryID, ImporterEventKind eventKind, int eventCode, string eventMsg)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusTLBImportConverterEventSchema record =
             new ComPlusTLBImportConverterEventSchema(iid, typeLibraryID, eventKind, eventCode, eventMsg);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int v, string description, Type contractType, Binding binding)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusTypedChannelBuilderSchema record = new ComPlusTypedChannelBuilderSchema(contractType.ToString(),
                                                                                        (binding != null) ? (binding.GetType()).ToString() : null);
         TraceUtility.TraceEvent(type, v, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, ContractDescription contract)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         XmlQualifiedName contractQName = new XmlQualifiedName(contract.Name, contract.Namespace);
         ComPlusServiceHostCreatedServiceContractSchema record = new
                                                                 ComPlusServiceHostCreatedServiceContractSchema(info.AppID, info.Clsid,
                                                                                                                contractQName, contract.ContractType.ToString());
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Uri from, string action, string callerIdentity,
                          Guid iid, int instanceID, Guid guidIncomingTransactionID)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusMethodCallNewTxSchema record = new ComPlusMethodCallNewTxSchema(from, info.AppID, info.Clsid, iid, action,
                                                                                instanceID, System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity,
                                                                                guidIncomingTransactionID);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, ServiceEndpointCollection endpointCollection)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         foreach (ServiceEndpoint endpoint in endpointCollection)
         {
             ComPlusServiceHostCreatedServiceEndpointSchema record =
                 new ComPlusServiceHostCreatedServiceEndpointSchema(info.AppID, info.Clsid, endpoint.Contract.Name,
                                                                    endpoint.Address.Uri, endpoint.Binding.Name);
             TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
         }
     }
 }
        public static void Trace(TraceEventType type, int traceCode, string description, Dictionary <MonikerHelper.MonikerAttribute, string> propertyTable)
        {
            if (DiagnosticUtility.ShouldTrace(type))
            {
                string address                 = null;
                string contract                = null;
                string binding                 = null;
                string bindingConfig           = null;
                string spnIdentity             = null;
                string upnIdentity             = null;
                string dnsIdentity             = null;
                string wsdlText                = null;
                string mexAddress              = null;
                string mexBinding              = null;
                string mexBindingConfiguration = null;
                string mexSpnIdentity          = null;
                string mexUpnIdentity          = null;
                string mexDnsIdentity          = null;
                string contractNamespace       = null;
                string bindingNamespace        = null;



                WsdlNS.ServiceDescription wsdl = null;
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out wsdlText);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out contract);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out address);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out binding);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingConfiguration, out bindingConfig);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out spnIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out upnIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out dnsIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexAddress, out mexAddress);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexBinding, out mexBinding);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexBindingConfiguration, out mexBindingConfiguration);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexSpnIdentity, out mexSpnIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexUpnIdentity, out mexUpnIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexDnsIdentity, out mexDnsIdentity);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out contractNamespace);
                propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out bindingNamespace);

                if (!String.IsNullOrEmpty(wsdlText))
                {
                    TextReader reader = new StringReader(wsdlText);
                    wsdl = WsdlNS.ServiceDescription.Read(reader);
                }
                ComPlusServiceMonikerSchema record = new ComPlusServiceMonikerSchema(address, contract, contractNamespace, wsdl, spnIdentity, upnIdentity,
                                                                                     dnsIdentity, binding, bindingConfig, bindingNamespace, mexAddress, mexBinding, mexBindingConfiguration, mexSpnIdentity, mexUpnIdentity, mexDnsIdentity);
                TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
            }
        }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, ServiceDescription service)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         WsdlExporter     exporter     = new WsdlExporter();
         string           serviceNs    = NamingHelper.DefaultNamespace;
         XmlQualifiedName serviceQName = new XmlQualifiedName("comPlusService", serviceNs);
         exporter.ExportEndpoints(service.Endpoints, serviceQName);
         WsdlNS.ServiceDescription wsdl = exporter.GeneratedWsdlDocuments[serviceNs];
         ComPlusServiceHostStartedServiceDetailsSchema record =
             new ComPlusServiceHostStartedServiceDetailsSchema(info.AppID, info.Clsid, wsdl);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceEndpointCollection serviceEndpointsRetrieved)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         int nIndex = 0;
         ComPlusMexBuilderMetadataRetrievedEndpoint[] endpoints = new ComPlusMexBuilderMetadataRetrievedEndpoint[serviceEndpointsRetrieved.Count];
         foreach (ServiceEndpoint endpoint in serviceEndpointsRetrieved)
         {
             endpoints[nIndex++] = new ComPlusMexBuilderMetadataRetrievedEndpoint(endpoint);
         }
         ComPlusMexBuilderMetadataRetrievedSchema record = new ComPlusMexBuilderMetadataRetrievedSchema(endpoints);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, Guid appid, Guid clsid, ServiceElement service)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         foreach (ServiceEndpointElement endpointElement in service.Endpoints)
         {
             ComPlusDllHostInitializerAddingHostSchema record =
                 new ComPlusDllHostInitializerAddingHostSchema(appid, clsid, service.BehaviorConfiguration, service.Name,
                                                               endpointElement.Address.ToString(), endpointElement.BindingConfiguration, endpointElement.BindingName, endpointElement.BindingNamespace,
                                                               endpointElement.Binding, endpointElement.Contract);
             TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
         }
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description,
                          Dictionary <UInt32, System.ServiceModel.ComIntegration.DispatchProxy.MethodInfo> dispToOperationDescription)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         UInt32 dispIndex = 10;
         System.ServiceModel.ComIntegration.DispatchProxy.MethodInfo methodInfo = null;
         while (dispToOperationDescription.TryGetValue(dispIndex, out methodInfo))
         {
             ComPlusDispatchMethodSchema record = new ComPlusDispatchMethodSchema(methodInfo.opDesc.Name, methodInfo.paramList, methodInfo.ReturnVal);
             TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
             dispIndex++;
         }
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Message message, int instanceID, Guid incomingTransactionID)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         WindowsIdentity callerIdentity = MessageUtil.GetMessageIdentity(message);
         Uri             from           = null;
         if (message.Headers.From != null)
         {
             from = message.Headers.From.Uri;
         }
         ComPlusInstanceCreationSuccessSchema record =
             new ComPlusInstanceCreationSuccessSchema(info.AppID, info.Clsid,
                                                      from, incomingTransactionID, callerIdentity.Name, instanceID);
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record, null, null, message);
     }
 }
Beispiel #19
0
        int CalcSessionGramSize()
        {
            long sessionGramSize = 0;

            for (int i = 0; i < this.buffers.Count; i++)
            {
                ArraySegment <byte> buffer = this.buffers[i];
                sessionGramSize += buffer.Count;
            }

            if (sessionGramSize > int.MaxValue)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.GetString(SR.MsmqSessionGramSizeMustBeInIntegerRange)));
            }

            return((int)sessionGramSize);
        }
Beispiel #20
0
        public void ReadIssuedTokens(Message message, MessageDirection direction)
        {
            TransactionFlowOption option = this.factory.FlowIssuedTokens;

            ICollection <RequestSecurityTokenResponse> issuances = this.GetIssuedTokens(message);

            if (issuances != null && issuances.Count != 0)
            {
                if (option == TransactionFlowOption.NotAllowed)
                {
                    FaultOnMessage(message, SR.GetString(SR.IssuedTokenFlowNotAllowed), FaultCodeConstants.Codes.IssuedTokenFlowNotAllowed);
                }

                foreach (RequestSecurityTokenResponse rstr in issuances)
                {
                    TransactionFlowProperty.Ensure(message).IssuedTokens.Add(rstr);
                }
            }
        }
Beispiel #21
0
            public void VoteRequestDone(int hr, int reason)
            {
                if (this.preparingEnlistment == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.GetString(SR.NoVoteIssued)));
                }

                if (S_OK == hr)
                {
                    this.preparingEnlistment.Prepared();
                }
                else
                {
                    this.preparingEnlistment.ForceRollback();
                    ComPlusTxProxyTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationTxProxyTxAbortedByContext,
                                              SR.TraceCodeComIntegrationTxProxyTxAbortedByContext, proxy.AppId, proxy.Clsid, transaction.TransactionInformation.DistributedIdentifier, proxy.InstanceID);
                }
            }
        public static void Trace(TraceEventType type, int traceCode, string description, XmlQualifiedName bindingQname, XmlQualifiedName contractQname,
                                 WsdlNS.ServiceDescription wsdl, ContractDescription contract, Binding binding, XmlSchemas schemas)
        {
            if (DiagnosticUtility.ShouldTrace(type))
            {
                string name = "Service";
                if (wsdl.Name != null)
                {
                    name = wsdl.Name;
                }
                Type contractType = contract.ContractType;

                XmlQualifiedName serviceName = new XmlQualifiedName(name, wsdl.TargetNamespace);
                foreach (XmlSchema schema in schemas)
                {
                    ComPlusWsdlChannelBuilderSchema record = new ComPlusWsdlChannelBuilderSchema(bindingQname, contractQname, serviceName,
                                                                                                 (contractType != null) ? contractType.ToString() : null, (binding != null) ? (binding.GetType()).ToString() : null, schema);
                    TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
                }
            }
        }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Uri from, string action, string callerIdentity,
                          Guid iid, int instanceID, bool traceContextTransaction)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusMethodCallSchema record = null;
         Guid guidContextTrsansactionID = Guid.Empty;
         if (traceContextTransaction)
         {
             IComThreadingInfo comThreadingInfo;
             comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
             if (comThreadingInfo != null)
             {
                 IObjectContextInfo contextInfo = comThreadingInfo as IObjectContextInfo;
                 if (contextInfo != null)
                 {
                     if (contextInfo.IsInTransaction())
                     {
                         contextInfo.GetTransactionId(out guidContextTrsansactionID);
                     }
                 }
             }
             if (guidContextTrsansactionID != Guid.Empty)
             {
                 record = new ComPlusMethodCallContextTxSchema(from, info.AppID, info.Clsid, iid, action,
                                                               instanceID, System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity, guidContextTrsansactionID);
             }
         }
         else
         {
             record = new ComPlusMethodCallSchema(from, info.AppID, info.Clsid, iid, action,
                                                  instanceID, System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity);
         }
         if (record != null)
         {
             TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
         }
     }
 }
Beispiel #24
0
        protected TransactionChannel(ChannelManagerBase channelManager, TChannel innerChannel)
            : base(channelManager, innerChannel)
        {
            this.factory = (ITransactionChannelManager)channelManager;

            if (this.factory.TransactionProtocol == TransactionProtocol.OleTransactions)
            {
                this.formatter = TransactionFormatter.OleTxFormatter;
            }
            else if (this.factory.TransactionProtocol == TransactionProtocol.WSAtomicTransactionOctober2004)
            {
                this.formatter = TransactionFormatter.WsatFormatter10;
            }
            else if (this.factory.TransactionProtocol == TransactionProtocol.WSAtomicTransaction11)
            {
                this.formatter = TransactionFormatter.WsatFormatter11;
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new ArgumentException(SR.GetString(SR.SFxBadTransactionProtocols)));
            }
        }
 public static void Trace(TraceEventType type, int traceCode, string description)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         Guid guidLogicalThreadID = Guid.Empty;
         Guid guidActivityID      = Guid.Empty;
         IComThreadingInfo comThreadingInfo;
         comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
         if (comThreadingInfo != null)
         {
             comThreadingInfo.GetCurrentLogicalThreadId(out guidLogicalThreadID);
             IObjectContextInfo contextInfo = comThreadingInfo as IObjectContextInfo;
             if (contextInfo != null)
             {
                 contextInfo.GetActivityId(out guidActivityID);
             }
         }
         ComPlusActivitySchema record =
             new ComPlusActivitySchema(guidActivityID, guidLogicalThreadID,
                                       System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId());
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
Beispiel #26
0
        void ReadTransactionFromMessage(Message message, TransactionFlowOption txFlowOption)
        {
            TransactionInfo transactionInfo = null;

            try
            {
                transactionInfo = this.formatter.ReadTransaction(message);
            }
            catch (TransactionException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                FaultOnMessage(message, SR.GetString(SR.SFxTransactionDeserializationFailed, e.Message), FaultCodeConstants.Codes.TransactionHeaderMalformed);
            }

            if (transactionInfo != null)
            {
                TransactionMessageProperty.Set(transactionInfo, message);
            }
            else if (txFlowOption == TransactionFlowOption.Mandatory)
            {
                FaultOnMessage(message, SR.GetString(SR.SFxTransactionFlowRequired), FaultCodeConstants.Codes.TransactionHeaderMissing);
            }
        }
Beispiel #27
0
        // NOTE: Construction of this thing is quite inefficient-- it
        //       has several nested loops that could probably be
        //       improved. Such optimizations have been left for when
        //       it turns out to be a performance problem, for the
        //       sake of simplicity.
        //
        public ServiceInfo(Guid clsid,
                           ServiceElement service,
                           ComCatalogObject application,
                           ComCatalogObject classObject,
                           HostingMode hostingMode)
        {
            // Simple things...
            //
            this.service           = service;
            this.clsid             = clsid;
            this.appid             = Fx.CreateGuid((string)application.GetValue("ID"));
            this.partitionId       = Fx.CreateGuid((string)application.GetValue("AppPartitionID"));
            this.bitness           = (Bitness)classObject.GetValue("Bitness");
            this.transactionOption = (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> >();

            // Isolation Level
            COMAdminIsolationLevel adminIsolationLevel;

            adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel");
            switch (adminIsolationLevel)
            {
            case COMAdminIsolationLevel.Any:
                this.isolationLevel = IsolationLevel.Unspecified;
                break;

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

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

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

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

            default:
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                                                                              SR.GetString(SR.InvalidIsolationLevelValue,
                                                                                           this.clsid, adminIsolationLevel)));
            }

            // Threading Model
            //
            COMAdminThreadingModel adminThreadingModel;

            adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel");
            switch (adminThreadingModel)
            {
            case COMAdminThreadingModel.Apartment:
            case COMAdminThreadingModel.Main:
                this.threadingModel  = ThreadingModel.STA;
                objectPoolingEnabled = false;
                break;

            default:
                this.threadingModel  = ThreadingModel.MTA;
                objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled");
                break;
            }

            // Object Pool settings
            //

            if (objectPoolingEnabled)
            {
                maxPoolSize = (int)classObject.GetValue("MaxPoolSize");
            }
            else
            {
                maxPoolSize = 0;
            }
            // Security Settings
            //
            bool appSecurityEnabled;

            appSecurityEnabled = (bool)application.GetValue(
                "ApplicationAccessChecksEnabled");
            if (appSecurityEnabled)
            {
                bool classSecurityEnabled;
                classSecurityEnabled = (bool)classObject.GetValue(
                    "ComponentAccessChecksEnabled");
                if (classSecurityEnabled)
                {
                    this.checkRoles = true;
                }
            }

            // Component Roles
            //
            ComCatalogCollection roles;

            roles = classObject.GetCollection("RolesForComponent");
            this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles);
            // Contracts
            // One ContractInfo per unique IID exposed, so we need to
            // filter duplicates.
            //
            this.contracts = new List <ContractInfo>();
            ComCatalogCollection interfaces;

            interfaces = classObject.GetCollection("InterfacesForComponent");
            foreach (ServiceEndpointElement endpoint in service.Endpoints)
            {
                ContractInfo contract = null;
                if (endpoint.Contract == ServiceMetadataBehavior.MexContractName)
                {
                    continue;
                }

                Guid iid;
                if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid))
                {
                    // (Filter duplicates.)
                    bool duplicate = false;
                    foreach (ContractInfo otherContract in this.contracts)
                    {
                        if (iid == otherContract.IID)
                        {
                            duplicate = true;
                            break;
                        }
                    }
                    if (duplicate)
                    {
                        continue;
                    }

                    foreach (ComCatalogObject interfaceObject in interfaces)
                    {
                        Guid otherInterfaceID;
                        if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID))
                        {
                            if (otherInterfaceID == iid)
                            {
                                contract = new ContractInfo(iid,
                                                            endpoint,
                                                            interfaceObject,
                                                            application);
                                break;
                            }
                        }
                    }
                }

                if (contract == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                                                                                  SR.GetString(SR.EndpointNotAnIID,
                                                                                               clsid.ToString("B").ToUpperInvariant(),
                                                                                               endpoint.Contract)));
                }
                this.contracts.Add(contract);
            }
        }
Beispiel #28
0
 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // Abort if this happens before all messges are consumed
     if (this.channel.State == CommunicationState.Opened && this.channel.InternalPendingItems > 0)
     {
         Exception e = DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqSessionChannelsMustBeClosed)));
         preparingEnlistment.ForceRollback(e);
         this.channel.Fault();
     }
     else
     {
         preparingEnlistment.Done();
     }
 }
Beispiel #29
0
            public void Prepare(PreparingEnlistment preparingEnlistment)
            {
                // Abort if this happens before all messges are consumed
                // Note that we are not placing any restriction on the channel state
                if (this.channel.TotalPendingItems > 0 || this.channel.sessiongramDoomed)
                {
                    Exception e = DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqSessionChannelHasPendingItems)));
                    this.sessiongramReceiveContext.Abandon(TimeSpan.MaxValue);
                    preparingEnlistment.ForceRollback(e);
                    this.channel.Fault();
                }
                else
                {
                    Transaction savedTransaction = Transaction.Current;
                    // complete the sessiongram message within this transaction
                    try
                    {
                        Transaction.Current = this.transaction;

                        try
                        {
                            this.sessiongramReceiveContext.Complete(TimeSpan.MaxValue);
                            preparingEnlistment.Done();
                        }
                        catch (MsmqException msmqex)
                        {
                            preparingEnlistment.ForceRollback(msmqex);
                            this.channel.Fault();
                        }
                    }
                    finally
                    {
                        Transaction.Current = savedTransaction;
                    }
                }
            }
Beispiel #30
0
        void VerifyTransaction()
        {
            if (this.InternalPendingItems > 0)
            {
                if (this.associatedTx != Transaction.Current)
                {
                    RollbackTransaction(null);
                    this.Fault();
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new InvalidOperationException(SR.GetString(SR.MsmqSameTransactionExpected)));
                }

                if (TransactionStatus.Active != Transaction.Current.TransactionInformation.Status)
                {
                    RollbackTransaction(null);
                    this.Fault();
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new InvalidOperationException(SR.GetString(SR.MsmqTransactionNotActive)));
                }
            }
        }