الاثنين، 30 ديسمبر 2013

How to add System.IO.Packaging reference

add a reference to the WindowsBase Assembly.

CRM 2011:Create a Picklist That Uses a Global Option Set

// Create a picklist attribute   

                PicklistAttributeMetadata pickListAttribute = new PicklistAttributeMetadata();
                // Set base properties
                pickListAttribute.SchemaName = "new_ExampleOptionSet";
                pickListAttribute.DisplayName = new Label("Example OptionSet", 1033);
                pickListAttribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None);
                //pickListAttribute.OptionSet = optionset;
                pickListAttribute.OptionSet = new OptionSetMetadata
                {
                    IsGlobal = true,
                    Name = _globalOptionSetName,
                };
                CreateAttributeRequest createAttribute = new CreateAttributeRequest();

                createAttribute.EntityName = EntityName;
                createAttribute.Attribute = pickListAttribute;
                // Execute the request.
                _Service.Execute(createAttribute);



//************************************************
http://msdn.microsoft.com/en-us/library/gg334416.aspx

الاثنين، 16 ديسمبر 2013

CRM2011:Could not find default endpoint element that references contract 'OracleService' in the ServiceModel client configuration section.

This error occur when you try run custom step workflow which call WCF service in dll file.
To solve to problem do the following:

1-Open cmd
2-run::  cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64
3-run: svcutil.exe WCFServiceURL /out:"C:\ServiceOutFolder\ServiceName.cs" /config:""C:\ServiceOutFolder\ServiceName.config"
4- Copy the "ServiceName.cs" and "ServiceName.config" file to your Project code.
5- Write the following code to get Service Client:
           BasicHttpBinding myBinding = new BasicHttpBinding();
            myBinding.Name = "BindingName";    // from AppConfig File
            myBinding.Security.Mode = BasicHttpSecurityMode.None;
            myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            EndpointAddress endPointAddress = new  EndpointAddress("WCFServiceURL");

            ServiceNameClient client = new ServiceNameClient(myBinding, endPointAddress);  // for ex:OracleServiceClient

// Now use this client to call methods in Service
            MyServiceName sv = client;


Your Service URL ex: http://localhost/OracleWS/OracleService.svc?wsdl