Freigeben über


Use Visual Studio 2005 to build CRM Callouts!

You already can develop web services applications for CRM V3.0 using Visual Studio(VS) 2003 or 2005 (or any IDE that supports web service standards for that matter). This is because our web services uses WSDL standard that is platform and tool independent.

 

However, building Callouts for CRM V3.0 is officially supported only on VS 2003. The explanation is rather simple. CRM platform itself is built on .NET Framework V1.1 and VS 2003. The platform runs as part of the IIS process and Callouts are loaded in that process when web services are called. Common Language Runtime (CLR) does not support loading two versions of .NET code into the same process (from my old days at VS team there are a lot of reasons for that including complexity of versioning, isolation and upgrade, etc). So if you build and compile your Callout using VS 2005, the callout cannot be loaded by our platform and you get an error.

 

I have been asked by many partners why they can’t use VS 2005 to build their callouts so decided to carve off some time and try to find a solution for the problem and here we are. VS 2005 uses MSBuild which allows you to target different runtimes (e.g. .NET 1.1 or even a non Microsoft commanline compiler). However, the VS team hasn’t got around to integrate the MSBuild with the VS IDE "yet" (watch out for VS Orcas plans). This means that out-of-the-box you don’t see any features in VS IDE that lets you target different runtime versions. That is where this article becomes useful.

 

I have created a VS 2005 project template for Callouts which 1) Allows you to build, compile and debug your callouts in VS 2005 by leveraging MSBuild 2) It gives your coding a kick start by providing the basic files and template code that you need to build a callout solution.

 

The project template uses the a readymade .NET V1.1 target file provided by Jomo Fisher blog. It also includes the CRM callout library that you need to compile the callout and the methods that you need to override. I have wrapped the template in an MSI package so you can easy install it on your machine by right clicking on the MSI file and selecting “Install”. The install just copies the template files into your machine and you can later on uninstall the package by going to the control panel and using Add/Remove Programs ( the name of the package is “Microsoft Dynamics CRM Templates”).

 

So let’s get started:

 

1. Make sure you have Visual Studio 2005 and .NET 1.1 (runtime only) installed on your box (if you are on a Windows 2003 machine .NET 1.1 is already installed by default, if you are on XP or other versions of Windows, it is very likely that an earlier application has already installed the .NET 1.1 for you otherwise you can get it from here).

 

2. Download the attached MSI (CRMTemplates.msi) and right click on the file and select “Install”.

 

3. Click next through the installation wizard – Don’t change any of the default settings.

 

4. When the install is complete, open VS 2005 and from file menu select New -> Project. You should see the below screen in the New project windows. As you notice under CRM node there is a new Callout Library project.

 

 

 

5. Select “Callout Library” as your template, select a name for your project and click “OK”.

 

6. You will see a warning dialog telling you about loading a custom project template. Select “Load project normally” and click OK without changing the rest of the default values as shown below.

 

 

 

8. VS will create a new project for you. If you notice on the build configuration manager, you have a new selection “.NET 1.1” which enables you to build a .NET 1.1 assembly.

9. Select MyCallout.cs file. You will see that I have already included all the methods that you can override in order to build your callout. I have also included the library that you need to include in your project (Microsoft.Crm.Platform.Callout.Base.dll).

10. Build your callout and compile it. It should be compiled as a .NET 1.1 assembly. As you can see I have targeted the built dll to be dropped into a “.NET 1.1” folder.

 

 

Some interesting notes:

1. You can have a VS solution with multiple projects that have different runtime target. For example, you can create a CRM Solution in VS, add a callout project that targets .NET 1.1 and a Web service application project that targets .NET 2.0.

2. Workflow assemblies should compile and run fine using VS 2005 and .NET 2.0 (although not supported/tested) so you don’t need a target or template to build those assemblies. If I can get some more free time I might also build a new VS template for workflow assemblies.

3. If you prefer not to use my MSI, you can build your own template or create a different project type that targets .NET 1.1 using MSBuild and targets. Read Jomo’s blog (link above) on how to use MSBuild and targets to do this manually. It is not really hard but you need to learn a bit about MSBuild to get started.

4. Remember that you are using VS 2005 to build a VS 2003 library. Although you will be enjoying new VS 2005 IDE features, not all the new VS 2005 features can be used to compile your V1.1 assembly (e.g. Generics). The good thing is that the compiler should tell you if you are crossing the line.

 

Let me know if you found a bug in the MSI or have issues, otherwise happy coding….

CRMTemplates.msi

Comments

  • Anonymous
    August 24, 2006
    Hi Arash,

    Thanks for the template, this is great! Now I can finally remove VS2003 from my dev VPC and save some space :)

  • Anonymous
    August 24, 2006
    Is this related with MSBee in any way?

  • Anonymous
    August 25, 2006
    Awesome!  Thanks for this tip, I was just about to install VS 2003 to write a callout. :-)

  • Anonymous
    August 27, 2006
    Hasta ahora la mayoría de los que hacemos desarrollos para Microsoft CRM 3.0 nos veíamos obligados a

  • Anonymous
    August 29, 2006
    Hi Arash

    Nice article, have to try this out later. How about workflow assemblies ? Could they be also run under framework 2.0 ?

  • Anonymous
    August 30, 2006
    Luis
    The tempate uses MSBuild that was shipped with Visual Studio 2005.   MSBee is simply some extra toolkits to top of MSBuild.

  • Anonymous
    August 30, 2006
    Nordic
    You can try building your Workflow assemblies with .NET 2.0.  They should work but we have only tested them with .NET 1.1.  To be on the safe side you can use the same callout template, remove the callout assembly refrence and compile your workflow assembly against .NET 1.1.  If i get some free time, i'll try to build a workflow assembly template.

  • Anonymous
    September 01, 2006
    What folder should this be installed in?  I use a non-standard install for VS2005, so when I install this it doesn't show up as in the screen shot.

    Thanks

    Cap

  • Anonymous
    September 05, 2006
    Cappy
    It insalls the template in C:Documents and Settings[your user name]My DocumentsVisual Studio 2005TemplatesProjectTemplatesVisual C#CRM.  You can copy the .zip file from this folder to the folder that you VS is looking for templates in.

  • Anonymous
    September 05, 2006


    When you use the VS 2005 callout template that I posted earlier you can take advantage of most of...

  • Anonymous
    September 07, 2006
    The comment has been removed

  • Anonymous
    September 08, 2006
    Bruno
    Setting.Designer.cs is a new Visual Studio 2005 feature(enables you to manage your project settings) therefore, it is not undrestood by .NET v1.1 compiler (that is the compiler that you are compiling your project with).  Simply delete this file from your project and you should be able to compile.

  • Anonymous
    September 11, 2006
    Hi I am using your callout application as above however I get errors in references.cs. How do I correct this?

    Many thanks

    Sid

  • Anonymous
    September 12, 2006
    Whenever I talk to people about Windows SharePoint Services and Microsoft Dynamics CRM everyone wants...

  • Anonymous
    September 12, 2006
    Hi Sid
    You need to create your proxy manually using instructions here http://blogs.msdn.com/arash/archive/2006/09/06/742434.aspx

  • Anonymous
    October 07, 2006
    In our Saturday morning CRM study group this morning we started our study for the CRM Customization exam....

  • Anonymous
    October 10, 2006
    The following blog posts demonstrate techniques and tools designed to improve your efficiency and ease

  • Anonymous
    October 24, 2006
    If you uninstall it, it eradicates the Visual C# folder under project templates.  That looks like a bug.

  • Anonymous
    December 05, 2006
    Nice template, but when I trying to build project, I get about 1000 errors - csc.exe v.1.1 doesn't understand VS2005 auto generated proxy class for CRM web-service... What should I do with this?..

  • Anonymous
    January 10, 2007
    The comment has been removed

  • Anonymous
    January 10, 2007
    OsaDRead this,You need to create your proxy manually using instructions here http://blogs.msdn.com/arash/archive/2006/09/06/742434.aspx

  • Anonymous
    February 02, 2007
    First, great template.  This will save me some time tonight, and I thank you.Second, let me tell you about a couple of changes I made in my project to make the build process a little easier for me.  This assumes you don't mind clobbering your existing callout code each build.  1) I changed the build output folder to go right to the assembly folder2) I added the following pre and post build eventsPREBUILD:net stop "Microsoft CRM Workflow service"iisreset /stopPOSTBUILD:iisreset /startnet start "Microsoft CRM Workflow service"3) Unchecked "Enable the Visual Studio Hosting Process" on the debug tab.4) Made my Start Action "Start Browser with URL" http://localhostNow I just need to get the debugger properly attached and symbols loaded and I'm all set for a much nicer experience.  Thank you again.

  • Anonymous
    February 15, 2007
    Développement côté client: (une bonne ressource pour les participants au challenge Javascript ;-) ) JScript

  • Anonymous
    February 22, 2007
    Simply great chunk of knowledge....GREAT!!!

  • Anonymous
    March 07, 2007
    Hi, this looks great,but I'm getting Compiler Errors within Setting.Designer.cs..My auto-generated Settings-File looks like://------------------------------------------------------------------------------// <auto-generated>//     This code was generated by a tool.//     Runtime Version:2.0.50727.42////     Changes to this file may cause incorrect behavior and will be lost if//     the code is regenerated.// </auto-generated>//------------------------------------------------------------------------------namespace MyCallOut.Properties {   [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]   [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]   internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {       private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));       public static Settings Default {           get {               return defaultInstance;           }       }   }}and I'm getting errors like "Identifier expected", "{ expected" and so on..What am I doing wrong? Could somebody help me?Thanx 1000xRegardsVana

  • Anonymous
    March 07, 2007
    Good, I've deleted the Settings.Designer class and now I see, this tool is not applicable for CallOuts worling with CrmService... I'm not able to comlpile  the project.. funny error messagers within Reference.cs are comming..:(Cheers

  • Anonymous
    March 07, 2007
    OK, I've replaced the CrmSdk-Reference files with those I had created once before with VS2003 and now I was able to compile the project. If it works, let's see, I'll give yoo the response if tested. This issue could be usefull for you: CrmService SDK Reference MUST BE created with VS2003! Cheers Vana

  • Anonymous
    May 23, 2007
    HiI used the template to create Callouts in VS 2005.Things seems to work but once I tried to access Post Entity XML and debug it using VS2005 I got exception thrown.The trace file showed exception in SQl and parsing the entityXML.have anybody faced such issues?Is it due to some schema parsing difference between VS 2003 and VS 2005?RegardsPritpal Singh

  • Anonymous
    July 07, 2008
    Hi, I would like to know if this template works with VS2008.Thanks a lot.