MscrmTools / MscrmTools.Xrm.Connection

Provides Winforms control to connect to Microsoft Dynamics CRM deployments
GNU Lesser General Public License v3.0
23 stars 38 forks source link

Exception in connecting via Connection string for on-premise environment #118

Closed imranakram closed 4 years ago

imranakram commented 4 years ago

Hello, I'm having a null reference exception when I go to New Connection -> Connection String -> just pasting an already working connection string. I have verified that the connection string works in my local fork based on older code.

Connection string looks something like this: url=https://orgname.xxxxxx.com/orgname;authtype=IFD;domain=xxxxx;username=xxxx\user.name;password=xxxxxx; This is a 9.0 onprem environment.

XrmToolBox version 1.2020.4.38

** Exception Text ** System.NullReferenceException: Object reference not set to an instance of an object. at McTools.Xrm.Connection.ConnectionDetail.get_UseOnline() at McTools.Xrm.Connection.WinForms.CustomControls.ConnectionLoadingControl..ctor(ConnectionDetail detail) at McTools.Xrm.Connection.WinForms.ConnectionWizard2.DisplayControl[T]() at McTools.Xrm.Connection.WinForms.ConnectionWizard2.btnNext_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

MscrmTools commented 4 years ago

Thank you for reporting this. I will check it

ramontebar commented 4 years ago

Hi guys, I noticed a similar error yesterday with the OAuth connection, like this one:

AuthType=OAuth; Username=tommy.shelby@mydomain.co.uk; Password=[mypassword]; Url=https://myorg.crm11.dynamics.com; AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97; TokenCacheStorePath=c:\MyTokenCache; LoginPrompt=Never

I run a quick test in the code, and it is coming from MscrmTools.Xrm.Connection-master\McTools.Xrm.Connection**ConnectionDetail.cs**

public bool UseOnline => OriginalUrl.IndexOf(".dynamics.com", StringComparison.InvariantCultureIgnoreCase) > 0;

Where the OriginalUrl is NULL

I have attached a screenshot, hope it helps.

XrmTool connection error OriginalUrl null

MscrmTools commented 4 years ago

Thanks I will review this

MscrmTools commented 4 years ago

The property OriginalUrl should always be set as it is taken from the URL defined by the user when setting the connection. This must be the source of this issue

MscrmTools commented 4 years ago

Code fixed to set OriginalUrl property when using a connection string

ramontebar commented 4 years ago

Code fixed to set OriginalUrl property when using a connection string

Thanks for the quick fix! We will wait for the next release to test it :)

MscrmTools commented 4 years ago

That will wait a bit... I have some work on XrmToolBox first... but once it’s done, connection controls will be able to be updated without updating XrmToolBox.