当前位置: 首页>>代码示例>>C#>>正文


C# OrganizationServiceProxy.Dispose方法代码示例

本文整理汇总了C#中OrganizationServiceProxy.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# OrganizationServiceProxy.Dispose方法的具体用法?C# OrganizationServiceProxy.Dispose怎么用?C# OrganizationServiceProxy.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrganizationServiceProxy的用法示例。


在下文中一共展示了OrganizationServiceProxy.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static public void Main(string[] args)
        {
            // The connection to the Organization web service.
            OrganizationServiceProxy serviceProxy = null;

            try
            {
                // Obtain the target organization's web address and client logon credentials
                // from the user by using a helper class.
                ServerConnection serverConnect = new ServerConnection();
                ServerConnection.Configuration config = serverConnect.GetServerConfiguration();

                // Establish an authenticated connection to the Organization web service. 
                serviceProxy = new OrganizationServiceProxy(config.OrganizationUri, config.HomeRealmUri,
                                                            config.Credentials, config.DeviceCredentials);

                CRUDOperations app = new CRUDOperations();

                // Create any records that must exist in the database. These record references are
                // stored in a collection so the records can be deleted later.
                EntityReferenceCollection records =
                    app.CreateRequiredEntityRecords(serviceProxy);

                // Perform the primary operation of this sample.
                app.Run(serviceProxy, records);

                // Delete all remaining records that were created by this sample.
                app.DeleteEntityRecords(serviceProxy, records, true);
            }

            // Some exceptions to consider catching.
            //<snippetCRUDOperations3>
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> e) { HandleException(e); }
            catch (TimeoutException e) { HandleException(e); }
            catch (SecurityTokenValidationException e) { HandleException(e); }
            catch (ExpiredSecurityTokenException e) { HandleException(e); }
            catch (MessageSecurityException e) { HandleException(e); }
            catch (SecurityNegotiationException e) { HandleException(e); }
            catch (SecurityAccessDeniedException e) { HandleException(e); }
            catch (Exception e) { HandleException(e); }
            //</snippetCRUDOperations3>

            finally
            {
                // Always dispose the service object to close the service connection and free resources.
                if (serviceProxy != null) serviceProxy.Dispose();

                Console.WriteLine("Press <Enter> to exit.");
                Console.ReadLine();
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:51,代码来源:CRUDOperations.cs


注:本文中的OrganizationServiceProxy.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。