Jaa


Start a managed code project in Visual Studio

 

Applies To: Dynamics CRM 2015

This topic shows you how to create a new project in Microsoft Visual Studio that’s properly configured to build a console application that uses the Microsoft Dynamics CRM SDK.

Prerequisites

  • Microsoft Visual Studio installed on your development computer.

    Any edition, including Visual Studio Express, should work. For more information about what versions of Microsoft Visual Studio are supported, see Visual Studio and the .NET Framework.

  • The Microsoft Dynamics CRM SDK installed on your development computer.

    Download the Microsoft Dynamics CRM SDK package. Run the downloaded executable file to unpack the package to any folder on your development system.

    Important

    For the 7.1.0 Preview release, the SDK assemblies will be available in NuGet packages only. A complete SDK download that includes the assemblies will be made available in the 7.1.0 RTM release.

Create a project

The following procedure demonstrates how to create a console application project in the C# or VB language that uses Microsoft .NET Framework 4.5.2. For more information on supported versions of the .NET Framework, see Supported extensions for Microsoft Dynamics CRM.

New project

  1. In Microsoft Visual Studio, select New Project.

  2. In the left navigation pane under Templates, select Visual C# or Visual Basic.

  3. Above the list of available templates, select .NET Framework 4.5.2.

  4. In the list of templates, select Console Application.

    A new console app project dialog in Dynamics CRM

  5. In the fields near the bottom of the form give the project a name and location, and then select OK.

  6. Under the Project menu, open the project’s properties form and verify the target framework is set to .NET Framework 4.5.2. Do not use .NET Framework 4.5.2 Client Profile.

    Choose the target framework for the CRM project

Add all required references to your project

The following procedures instruct you how to add all required assembly references to your project. Consider this a base set of references that most managed code applications will need for calling web service methods.

An alternate and easy method to add the required references to you project is to use the available NuGet SDK package. Using the NuGet package manager in Visual Studio, find and add the Microsoft.CrmSdk.CoreAssemblies package to your project. You can then skip the remaining instructions in this topic.

However, if you are writing an application that accesses the OData web service endpoint, you may not have to add SDK assembly references to your project. For more information about writing apps that access the OData endpoint, see Write mobile and modern apps.

Add the required system references

  1. In Solution Explorer, right-click the project References node, select Add References, and then add the following references to your project.

    • System.Data.Linq

    • System.DirectoryServices.AccountManagement

    • System.Runtime.Serialization

    • System.Security

    • System.ServiceModel

Add the required SDK assembly references

  1. In Solution Explorer, right-click the project References node, and then select Add References.

  2. In the Reference Manager dialog box, select the Browse button, and then navigate to the folder where you extracted the Microsoft Dynamics CRM SDK.

  3. In the Bin folder of the SDK download, select the Microsoft.Crm.Sdk.Proxy.dll and Microsoft.Xrm.Sdk.dll assemblies, and then click Add.

  4. Select OK.

There are other Microsoft Dynamics CRM SDK assembly references that you may need at some time depending on the nature of the project you’re building. However, for writing application code that accesses the organization web service, the previously mentioned references are all you need. More information: Assemblies included in the Microsoft Dynamics CRM SDK.

Add the required Identity references

  1. Download and install the Windows Identity Framework (WIF) version 3.5 library, named WindowsIdentityFoundation-SDK-3.5.msi.

  2. In Solution Explorer, right-click the project References node, and then select Add References.

  3. In the search box, enter System.IdentityModel.

  4. Select System.IdentityModel in the search results list and click OK.

  5. Similar to what was done in steps 2 to 4, add a reference for Microsoft.IdentityModel.

The following diagram shows all the required references added to a project.

Add the project references for the CRM project

Next Steps

Tip

Before you leave this topic, consider saving your project as a project template. You can then reuse that template for future learning projects and save yourself some time and effort in setting up new projects. To do this, while your project is open in Microsoft Visual Studio, in the File menu select Export template. Follow the wizard instructions to create the template.

See Also

Getting started with managed code application development

© 2016 Microsoft. All rights reserved. Copyright