Friday, September 07, 2007

Environment independent solutions

Developing CRM solutions that are environment independent is not trivial. By just adding a webservice you are making your code dependant on the CRM customization of that system. If you move the solution/dll:s to another system you will be running a risk of your code not working. This is especially problematic for ISVs since they never know what system their product will be installed on. However, there is a good way to handle it. The best way is to first use a plain out-of-the-box CRM system and use the program

C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\wsdl /out:c:\temp\myCRMProxyClass.cs http://localhost:5555/mscrmservices/2006/crmservice.asmx?wsdl

This will create a file called myCRMProxyClass.cs is c:\temp.

Add this to your project. This is in essence the same this as adding a web reference and adding "using CRMSDK" or whatever you named it. Hence you can access all the CRM webservice classes.

Then create the service-instance and set the url by using the registry-key added during the installation of Microsoft CRM. Have a look here if you want to know how.

If you have other environment specific data, it should be placed in the web.config / appsettings (if using a normal web-site/virtual directory) or you can use the AssemblySettings.dll (has to be downloaded, not from Microsoft) to create a assembly specific config-file, alternatively, add you own keys to the registry.

I hope I have given you a few hints on how this is done. Happy coding!


No comments:

Post a Comment