Hi,
I'm facing the below error while connecting to my Dynamics 365 Online Trial. I've gone through some of the solutions provided(e.g. updating to new SDK version etc), but none have helped, so posting this query here.
An exception of type 'System.InvalidOperationException' occurred in CRM Test Solution.dll but was not handled in user code
Metadata contains a reference that cannot be resolved: 'opsoftdec.api.crm8.dynamics.com/.../Organization.svc;sdkversion=8.2'.
The program '[2388] iisexpress.exe' has exited with code -1 (0xffffffff).
Following is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Xrm.Sdk;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using System.Net;
using Microsoft.Xrm.Sdk.Query;
namespace CRM_Test_Solution
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string _username = "username";
string _password = "password";
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = _username;
credentials.UserName.Password = _password;
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Uri organisationUri = new Uri("opsoftdec.api.crm8.dynamics.com/.../Organization.svc");
Uri homeRealmUri = null;
OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(organisationUri, homeRealmUri, credentials, null);
IOrganizationService service = serviceProxy;
}
catch (Exception ex)
{
throw ex;
}
}
*This post is locked for comments
What version of .NET is your project running in?
MS recently required the use of TLS 1.2 or later so you will need to run .NET 4.6.2 or later
blogs.msdn.microsoft.com/.../updates-coming-to-dynamics-365-customer-engagement-connection-security
Hi,
please refer to the following two links:
rajeevpentyala.com/.../dynamics-365-plug-in-registration-tool-connectivity-issues
www.mscrm.com/.../dynamics-crm-v9-d365-connection-error.html
Thanks.
venkateswarlu
Hi,
then i think you don't have any other choice, but change it to the method suggested by Pawel Gradecki.
hey.. There is one more think.. Check your network proxy. Same issue.. I was having. I added some code in web.config file to bypass the network issue.
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true">
</defaultProxy>
</system.net>
Add this to your solution in web.config after </syestem.web>
Hi,
Appreciate your help.
I tried with "https://opsoftdec.api.crm8.dynamics.com", but its resulting in the same error
Your way of connecting to Dynamics 365 is very outdated, I'm not sure where did you find your code but since few years there are much better ways of connecting. You should connect using Xrm.Tooling assembly. Here you will find the example:
[View:https://msdn.microsoft.com/pl-pl/library/jj602970.aspx:750:50]
Or:
https://msdn.microsoft.com/en-us/library/dn688177.aspx
The only part you need is this one:
CrmServiceClient conn = new Xrm.Tooling.Connector.CrmServiceClient(connectionString);
And of course you should build correctly your connection string (as you are using Online, it should be the one for Office 365) or use some other constructor of CrmServiceClient which does not require Connection String
Hi,
Change your url into "opsoftdec.api.crm8.dynamics.com" without the /.../Organization.svc"
("opsoftdec.api.crm8.dynamics.com/.../Organization.svc");
Uri homeRealmUri = null;
Hi,
Sorry for the error in my previous reply regarding the URL.
The URL in the code is already set using https://, as shown below, I had mentioned it incorrectly in my reply.
Uri organisationUri = new Uri("opsoftdec.api.crm8.dynamics.com/.../Organization.svc");
Uri homeRealmUri = null;
Hi,
change your url into "opsoftdec.api.crm8.dynamics.com" .
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6