Schlagwort-Archiv: Hints

Using HttpUtility.UrlEncode in a plugin leads to a SecurityException

In a recent project I had to develop a plugin which is executed in the plugin sandbox. The sandbox restricts the rights plugins to a ‘safe’ amount. See for a description. According to the SDK, web request are allowed.

Part of my task was to send a request to a web service which expects data URL-encoded. Normally you would use following class (part of System.Web)

HttpUtility.UrlEncode("some data here");

I was surprised that this leads to a SecurityException if used in a sand-boxed plugin. The sandbox does not allow the use of this class.

Instead of rewriting the method (I hate reinventing the wheel…) I’ve searched for a replacement, and found

Uri.EscapeDataString("some data here");

which is usable in sand-boxed plugins. For my task the result was the same as with UrlEncode, however I am not sure I they are different in their results.

Do I need that SPN?

One important thing that is often forgotten during/after the installation of Dynamics CRM is to properly set the SPNs for your service accounts (if necessary ;) ).
Here are three links which I often take as reference when we plan new deployments:

MissingMethodException at E-Mail-Router installation

This week I’ve installed the E-Mail-Router for a customer. During the setup an error came up

Action Microsoft.Crm.Setup.Exchange.GenerateEncryptionKeyAction failed.

Method not found: ‘Boolean Microsoft.Crm.ApplicationConfig.IsFederalInformationProcessingCompliant()’.

The cause of this error was a pending restart which was requested by Windows Update. I have no clue if a specific update was the cause of the problem, or the system state itself.
However, after rebooting the machine, the error went away and the setup was successful.

So keep in mind, if the pre-checks warns you about a pending reboot, it is sometimes better not to ignore this hint ;)

Why OptimizeOrgImport is not always an optimization

Update Rollup 8 introduced an improved organization import process which speeds up the organization import.

You have to enable the optimized import process by adding the DWORD key OptimizeOrgImport with value 1 to the registry hive of Dynamics CRM (see the detailed description

Recently, I had a problem during an import of an organization which failed with following error

Message: Exception during import of organization (Name=’‘, Id=3e58a0cc-c277-df11-b2c1-0050569473db):
System.Data.SqlClient.SqlException: A row with a duplicate key cannot be added to the object ‘dbo.SystemUserOrganizations’-object with unique index ‘SystemUserOrganizations_CrmUserId’

The organization which I tried to import was a backup of an organization which was created in the same deployment. The import runs successful on every other deployment. With help of the Microsoft Support, we identified the cause of the issue: the OptimizeOrgImport key.

The knowledgebase article for OptimizeOrgImport contains following passage:

When you use the registry entry OptimizeOrgImport and have the value of this entry set to 1, you cannot import the same organization database more than one time.
If you want to import the same organization database more than one time, you must do one of the following things:

  • Set OptimizeOrgImport = 0 and use the normal import process.
  • Delete the organization, and then import the organization again.

This passage is a little bit misleading, as the optimized import process fails already at the first time, if the organization was created in the same deployment. In order to import a backup of an organization into the originating deployment, you have to deactivate OptimizeOrgImport.