If you are working on code to merge two entity records and come across “Cannot specify child attribute retrieve” error; and you have referred SDK/MSDN documentation. You probably have kept UpdateContent property optional and havent set it. UpdateContent is a required property though the documentation says it is not.
This property is optional in case of merging incidents only.
You just have to set Entity object to UpdateContent property which has attributes to be updated to the merged record.
Entity contact = new Entity("contact");
contact["firstname"] = "Crm";
contact["lastname"] = "Xpress";
// merging contact records
MergeRequest merge = new MergeRequest
// SubordinateId is the GUID of the contact merging.
SubordinateId = contactId,
Target = target,
PerformParentingChecks = true,
UpdateContent = contact // Entity Object to set the content you want updated on the merged contact
I was porting a .Net 2.0 assembly to .Net 4.0 plugin assembly and faced this particular challenge.
The project had a test app(A WinForm app) and it worked fine on the desktop but when I deployed the logic on server to run as a plugin it gave the following error
xyz..GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext) Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Just notice, the spelling for “overridden” is also not correct. But this is what .Net framework threw.
After some research I found that this behavior is “By Design” i.e. as per security transparency model defined in .Net v4.0. It basically has two models:
1. Level1 (High Level) for v2.0
2. Level2 for v4.0
Here is a a list of critical operations:
1. Call native code
2. Contain unverifiable code
3. Call critical code
4. Perform security asserts
5. Satisfy link demands
6. Derive from non-transparent types
7. Override security critical virtuals
And only full trust code can be security critical.
Hence an overridden member should have the same security accessibility (Critical, Safe Critical or Transparent).
To resolve this error take the following step:
Go to the AssemblyInfo.cs class to your project and add following attributes to it. And this should resolve the exception.
I believe it might be helpful to many as there are lot of Dynamics CRM implementations being upgraded.
Reference links to the differences between both and transparency rules:
We had a requirement to get the current month name and its short name (example- November|Nov).
While DateTime class does not provide these methods out of .net framework, we had to create methods which gives the similar output.. We have created similar methods through Extension Methods supported with recent .net framework.
Extension methods can be used as instance methods and it uses “this” keyword as a parameter. They are static and they must be defined on static class.
Here is the solution:
static void Main(string args)
Console.WriteLine(DateTime.Today.Day + "." + DateTime.Today.Month + "." + DateTime.Today.Year);
// Update: Similar functionality can be achieved through below statements also.
// Thanks Michael for inputs.
static class DateTimeExtensions
public static string ToMonthName(this DateTime dateTime)
public static string ToShortMonthName(this DateTime dateTime)
Extension Methods in Visual Studio appears with special symbol:
Before some time I had a situation where my console application would not run and without showing any screen/anything else it gave me this alert mentioned below:
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
Most of the google links will guide you to check your VC++ runtime and their versions. I checked everything and everything was as expected as other applications were working smooth without any error.
Also, I checked with a simple “Hello world!” console application but the output was same. And with no clue to my mind I removed the .config file from the directory.
If same is your situation then, suggested solution would be to rename the extension of the .config file to .xml file and run/parse it to any browser. In my case the .xml file did not meet with the standards as an value contained & (ampersand) and it was breaking the it to be well formed xml document.
Check with the standard list of invalid xml characters so that you can avoid this kind of situation in future. Check this link – http://www.w3.org/TR/2000/REC-xml-20001006#charsets to see well-formed xml document rules.
CSV from List
public string GetCsvFromList(List<string> list)
return String.Join(",", list.Select(x => x.ToString()).ToArray());
List from CSV
public List<T> GetListFromCsv<T>(string commaSplited)
return (from e in commaSplited.Split(',')
select (T)Convert.ChangeType(e.Trim(), typeof(T))).ToList();
I was trying to Reset/Change Password for Active Directory through C# code behind. And I encountered with the same error:Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Access Denied errors that are reported by scripts and applications that access WMI namespaces and data generally fall into three categories.
Possible Reasons are:
The user does not have remote access to the computer through DCOM. Typically, DCOM errors occur when connecting to a remote computer with a different operating system versions.
Give the user Remote Launch and Remote Activation permissions in dcomcnfg.
- Right-click My Computer-> Properties Under COM Security, click “Edit Limits” for both sections.
- Give the user you want remote access, remote launch, and remote activation.
- Go to DCOM Config, find “Windows Management Instrumentation”, and give the user you want Remote Launch and Remote Activation.
For more information, see Connecting Between Different Operating Systems
If you have come to this blog searching for the error mentioned above then probably you’re doing some modifications to ADFS 2.0 site.
Following would be the symptoms that you have done so far:
- You have opened adfs\ls website as Website project in Visual Studio.
- If the project type is Website, you probably had a message from Visual Studio to upgrade for the .Net v4.0.
- You have created a new project Empty Web Application and imported adfs\ls website content to the project.
- You are modifying this site/application on local machine and not on Windows Server where ADFS is installed.
Follow these steps to successfully start modifying ADFS site:
- Install Visual Studio 2010 on Windows Server where ADFS is installed and configured.
- Create an Empty Web Application
- Import all the files from adfs\ls directory to the Web Application. (generally, you can find it on c:\inetpub\adfs\ls)
- Right click on the project in Solution Explorer and click on “Convert to Web Application”.
- You’re ready to go!
You do not need to add reference of any files to this web application. Just Build and Publish the site to the same directory where adfs is installed.
Microsoft.IdentityServer.Compression and other required files will be referenced from GAC as you are developing the project on the server itself.
Happy Programming! 🙂
When you try to access the Microsoft Dynamics CRM 2011 Web client, you get the following error.
Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089
This error can occur when there are multiple versions of the .NET Framework on the computer that is running IIS, and IIS was installed after .NET Framework 4.0 or before the Service Model in Windows Communication Foundation was registered.
1. Go to computer where CRM 2011 is installed and open command prompt.
2. Change the directory to C:\windows\Microsoft.NET\Framework64\v4.0.30319
3. Type the following command- aspnet_regiis.exe -iru
4. Reset the IIS by iisreset command.
We already have discussed how to achieve connection of CRM 2011 through .net version 3.5 from below mentioned post. https://consultrikin.wordpress.com/2013/09/20/crm-2011-c-entity-class-redefined-with-net-framwork-3-5-to-connect-crm-2011/
Once this is achieved and you start working on CRUD operations, you will find some run time exceptions thrown like one I have described below.
Type ‘OptionSetValue’ with data contract name ‘OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts’ is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.’. Please see InnerException for more details.
The same thing will be repeated for EntityReference and PicklistAttributeMetadata.
1. Explore the reference.cs from the project in Windows Explorer and open it.
2. Search for class Entity and class EntityReference
3. Add below lines to both partial classes.
4. Now search for “class OrganizationRequest”.
Add these lines above it:
5. Continue adding to classes for which you’re getting these exceptions.
6. Build the solution and run your code again.
Happy Programming! 🙂
We already discussed how a CRM 2011 web service can help us create object of OrganizationServiceProxy or Instance of IOrganizationService in my previous posts. This is the case when we’re not using assemblies from SDK and thus several SDK request and response messages will not be available to you like RetrieveAttributeRequest/Response etc.
All we have is OrganizationRequest and OrganizationResponse and in this case you will have to use OrganizationRequest and OrganizationResponse to request data from CRM 2011. See below example which uses similar example for RetrieveAttributeRequest.
OrganizationRequest request = new OrganizationRequest();
request.RequestName = "RetrieveAttribute";
request.Parameters = new ParameterCollection();
request.Parameters.Add(new KeyValuePair<string, object>("EntityLogicalName", "salesorder"));
request.Parameters.Add(new KeyValuePair<string, object>("RetrieveAsIfPublished", true));
request.Parameters.Add(new KeyValuePair<string, object>("LogicalName", "new_cardtype"));
OrganizationResponse response = (OrganizationResponse)CrmHelper.OrgService.Execute(request);
PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.Results.Value;
catch (FaultException<OrganizationServiceFault> ex)
throw new Exception("Error details: " + ex.Message);