This section walks you through the basic steps necessary to create a project inside Microsoft Visual Studio 2008, using Microsoft Dynamics CRM data and then displaying within Microsoft Dynamics CRM. In this project, we use the Visual Studio add-in for Silverlight. In this foundation project, we build a UI component using a VS.NET project and a data access component using WCF:
1. Open Visual Studio 2008.
2. Select File, New, and then Project.
3. In the Project selection window, select Silverlight Application (as shown in Figure 1).
Figure 1. Project selection in Visual Studio 2008.
4. Click OK.
5. In the Add Silverlight Application dialog box, select Automatically Generate a Test Page to Host Silverlight at Build Time. For production release, you can attach this to an existing ASP.NET application. By default, this will create two files in the Solution Explorer:
-
App.xaml is a file used to declare shared resources such as data grids and various style objects. The code behind this file is used for handling global events such as Application_Startup, Application_Exit, and Application_UnhandledException (see Figure 2).
Figure 2. Show sample app.xaml.
-
Page.xaml is the default file created. Typically, this is replaced with the new Silverlight page (see Figure 3).
Figure 3. Show sample page.xaml.
Create a WCF project in the same solution. WCF is used as the communication layer for the Silverlight application. WCF supports asynchronous connections between the Silverlight application and the backend data sources. Figure 4 shows the communication sequence between the client and the backend when a user is viewing CRM notes on the Account page using Silverlight and all the steps in between.
Figure 4. Sample of the process to extract data for Silverlight.
1. Right-click the solution and create a new WCF project.
2. Click Add.
3. Select New Project.
4. Select WCF Service Application, as shown in Figure 5.
Figure 5. Select WCF Service Application.
Once the new project is attached to the solution, build the necessary connection to the CRM system, whether it is using web services or direct SQL access. Some organizations prefer direct SQL access for reading, whereas other organizations prefer to use the web services.It is recommended to use Microsoft Dynamics CRM web services to read and write data. However, if your application is only reading data, you can access the SQL views and access data very easily.