本文整理汇总了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();
}
}