Saturday, July 28, 2018



         Functions Can be used to Authenticate Directly with MSCRM Web services



1. On Premise MSCRM Authenication Function


public static IOrganizationService GetXrmService(string _crmUserName, string _crmURL, string _crmDomain, string _crmPassword)
        {

            Uri organizationUri = new Uri(_crmURL);
            ClientCredentials cCredentials = new ClientCredentials();
            cCredentials.UserName.UserName = string.Format("{0}\\{1}", _crmDomain, _crmUserName);
            cCredentials.UserName.Password = _crmPassword;
            OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, null, cCredentials, null);
            orgProxy.EnableProxyTypes();
            _xrmService = (IOrganizationService)orgProxy;
            return _xrmService;
         

        }

2. Online Authenication function

       public static IOrganizationService GetOnlineXrmService(string _crmUserName, string _crmURL, string _crmDomain, string _crmPassword)
       {

           ClientCredentials credentials = new ClientCredentials();
           credentials.UserName.UserName = _crmUserName;
           credentials.UserName.Password = _crmPassword;
           credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
           //  credentials.Windows.ClientCredential = new System.Net.NetworkCredential(_userId, _password, _domain);

           Uri organizationUri = new Uri(_crmURL);
           Uri homeRealmUri = null;
         

           using (_serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null))
           {
               _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
               _xrmService = (IOrganizationService)_serviceProxy;
               _orgContext = new OrganizationServiceContext(_xrmService);
           }

           return _xrmService;

       }

Friday, February 9, 2018

CRM cannot find the plugin assembly or one of its dependencies”
OR
 How to use IL Merge with CRM Online ?
OR
 How to merge DLLs ?



Hi ,

D365 allows to deploy a single dll into the platform. Hence when required to use reference dll


CRM cannot find the plugin assembly or one of its dependencies  is a common scenario.


With Dynamics 365 round the corner, Situation of using  I L Merge is increasing every day.


While working on a plugin we encountered a situation where we had to use a reference dll.


CRM cannot find the plugin assembly or one of its dependencies.

To Resolve this We have used the Microsoft Tool ILmerge

There can be two methods to resolve the error

1) Copy the Dll which needs to be merged into the Ilmerge folder with references such as Microsoft.Xrm.Sdk.Proxy , Microsoft.Crm.Sdk , Strong Key File Which is used to sign the assemblies.

2) Also copy and paste mscorsn.dll from “C:\Windows\Microsoft.NET\Framework64\v4.0.30319” on your PC.

Remember Key must be of .snk type. (Dll Can be merged using .pfx but may  not work with CRM)




Type The Following Command to Merge the dll into cmd.

C:\Program Files (x86)\Microsoft\ILMerge>ilmerge /keyfile:Ilmerge.snk  /target:library /copyattrs /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319" /out:CompletePlugin.dll Plug_Ilmerge.dll Plug_Data.dll


Definition  :
CompletePlugin.dll – is a merged Dll
Plug_Ilmerge.dll  -- is a1st  plugin which is merged.
Plug_Data.dll – is a 2nd plugin which is to be merged.




Other Way is using Nugget Packages in VS 2013 onwards using IL which I would write off some other day.