I have serious problem with creating a connection to dynamics CRM online from my Window 8 metro style application.
My code works fine under normal (full) .net framework, but fails under WinRT
private IOrganizationService OrgService { get; set; }
private ClientCredentials ClientCreds { get; set; }
private ClientCredentials DeviceCreds { get; set; }
//(..)
ClientCreds = new ClientCredentials();
ClientCreds.UserName.UserName = "[email protected]";
ClientCreds.UserName.Password = "sample_password";
DeviceCreds = DeviceIdManager.LoadOrRegisterDevice();
Uri orgServiceUri = new Uri("https://sampleaddress.api.crm4.dynamics.com/XRMServices/2011/Organization.svc");
OrgService = new OrganizationServiceProxy(orgServiceUri, null, ClientCreds, DeviceCreds);
The last line of this code gives an exception:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Probably this class tries to save some file somewhere, which is not permitted in metro style apps.
Anybody can help with that ? How to bypass this behavior or OrganizationServiceProxy class ?