- Create a new Silverlight 4 Application named CRM2011OnlineSilverlightApp.
- Add Service Reference to the Organization.Svc (https://orgname.crm4.dynamics.com/XrmServices/2011/Organization.svc).
- crm for North America
- crm4 for Europe
-
crm5 for Asia
- Give the namespace as OrgServiceReference
- Give the namespace as OrgServiceReference
- Open the reference.cs and replace System.Collections.Generic.KeyValuePair with KeyValuePair

- Add the following helper files from the SDK (..\sdk\samplecode\cs\silverlight\soapforsilverlight\soapforsilverlightsample)
- silverlightextensionmethods.cs
-
silverlightutility.cs
- Rename namespace SoapForSilverlightSample.CrmSdk to CRM2011OnlineSilverlightApp.OrgServiceReference in silverlightextensionmethods.cs file.
- Add a Button and a TextBlock to our Silverlight application.

- Add the following code.
private void btnCreateContact_Click(object sender, RoutedEventArgs e)
{
// Get IOrganizationService instance
IOrganizationService myOrgService = SilverlightUtility.GetSoapService();
Entity myContact = new Entity();
myContact.LogicalName = "contact";
// Create the AttributeCollection
myContact.Attributes = new AttributeCollection();
// Specify Last Name and First Name for the contact to be created
KeyValuePair<string, object> myKVPLastName = new KeyValuePair<string, object>();
myKVPLastName.Key = "lastname";
myKVPLastName.Value = "Twain";
KeyValuePair<string, object> myKVPFirstName = new KeyValuePair<string, object>();
myKVPFirstName.Key = "firstname";
myKVPFirstName.Value = "Shania";
myContact.Attributes.Add(myKVPLastName);
myContact.Attributes.Add(myKVPFirstName);
OrganizationRequest myOrgRequest = new OrganizationRequest();
myOrgRequest.RequestName = "Create";
// call the Create method
myOrgService.BeginCreate(myContact, myCreateHandler, myOrgService);
}
private void myCreateHandler(IAsyncResult ar)
{
IOrganizationService orgService = ar.AsyncState as IOrganizationService;
Dispatcher.BeginInvoke(() =>
{
txtStatus.Text = "Contact Guid - " + orgService.EndCreate(ar);
});
}
-
Create a web resource in CRM and upload the XAP, and to test it add it to any form inside CRM.
-
Click on create to create the contact record.
- Download the project. (change the extension to zip from docx)
https://nishantrana.me/wp-content/uploads/2011/11/crm2011onlinesilverlightapp.docx












