Creating Environment independent solutions

When developing a solution for CRM, make sure that it runs on all different crm environments. Many implementations have their CRM installation on another port compared to the development environments. A way to handle this, is to look at the location of MS CRM as it is stored in the registery.

// Set default values
private const string CRM_REG_DIRECTORY = @"software\Microsoft\mscrm\";
private const string CRM_SERVICE_PATH = @"/2006/crmservice.asmx";

// Create CrmService instance
service = new CrmService();
service.Url = GetCRMWebServiceRoot() + CRM_SERVICE_PATH;

/// <summary>
/// Returns the recorded web location from the registry
/// </summary>
private static string GetCRMWebServiceRoot()
string result = null;
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(CRM_REG_DIRECTORY, false);
if (regKey != null)
result = (string) regKey.GetValue("ServerUrl");
throw new ApplicationException("Microsoft CRM could not be found on this computer.");
catch (Exception err)
throw new ApplicationException("Cannot retrieve registry value for CRM web service. " + err.Message);
return result;

Thanks to Richard McCormick for providing the codes :)


Anonymous said...

Hello Ronald,

I was having a problem in customising the order form in Microsoft CRM 3.0

I have 5 custom entities there on my order form havin a 1 to many relationship.
Now my problem is that when OI convert an order to invoice from the toolbar button I am not able tohave the custom entities m records in the created invoice form.

I am in a total mess & dontr know what to do...

Please help me out.


Ronald Lemmen said...


You would need to create the same relationships on the invoice entity. Then in the mapping between the order and invoice entities you would need to add the mapping between the attributes on the order to the invoice.

Hope this helps,


Packers And Movers Mumbai said...

Hire Best Packers And Movers Mumbai for hassle-free Household Shifting, ***Office Relocation, ###Car Transporation, Loading Unloading, packing Unpacking at affordable Price Quotation. Top Rated, Safe and Secure Service Providers who can help you with 24x7 and make sure a Untroubled Relocation Services at Cheapest/Lowest Rate @ Packers And Movers Mumbai