RE: Error in Console CRM Connection Class for Version 9.0.1.425
Hi Ravi,
Yes i am Using the Same V9 Dll's, But still getting the below mentioned Error.
Additional information: Unexpected exception from plug-in (Execute): ProfiledTypes.ProfilerTypefcddf078b1114aef9dded41a7589ad74: System.Security.SecurityException: The data contract type 'Microsoft.Xrm.Sdk.OrganizationServiceFault' cannot be serialized in partial trust because the property 'ExceptionRetriable' does not have a public getter.
Code Which i am using to connect.
class CrmConsoleConnection
{
static void Main(string[] args)
{
CrmConnection connectionClass = new CrmConnection();
IOrganizationService Service = connectionClass.Service("USerName@crm.onmicrosoft.com", "Crm@123", "", "crm.api.crm8.dynamics.com");
Entity EmployeeEntity = new Entity("new_employee");
EmployeeEntity["lvt_name"] = "Hi WElcome to CRM";
Service.Create(EmployeeEntity);--Error While Create on new__Employee record
}
}
public class CrmConnection
{
public IOrganizationService Service(string username, string password, string domain, string server)
{
System.IO.StreamWriter file = null;
IOrganizationService service = null;
string lines = "";
try
{
ClientCredentials cre = new ClientCredentials();
cre.UserName.UserName = username;
cre.UserName.Password = password;
Uri serviceUri = new Uri("crm.api.crm8.dynamics.com/.../Organization.svc");
//One Extra Line Perform the connection
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
proxy.EnableProxyTypes();
service = (IOrganizationService)proxy;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return service;
}
}
Regards,
Krishna.