0
votes

I am new to Dynamics CRM 2011 Online. I am try to generate the data context class using CrmSvcUtil.exe

This is my command:

CrmSvcUtil.exe /out:E:\OrgXrm.cs
/url:https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc
/username:[email protected] /password:Password

But its giving an error:

Exiting program with exception: An error occurred when verifying security for th e message. Enable tracing and view the trace files for more information. CrmSvcUtil.exe Error: 0 : Exiting program with exit code 2 due to exception : Sy stem.ServiceModel.FaultException: An error occurred when verifying security for the message.

4

4 Answers

1
votes

I was researching another issue when I ran across a post in the Microsoft forums that may help. I remembered this question so I thought I would post another answer as this one had a positive resolution.

Quote:

I have dealt with this one before. Verify the Time and Date settings (including timezones) are set correctly on both the server and your client machine. It seems that if the two machines are out of sync by more than a minute or two it will cause this problem.

On my client machine I had to restart Visual Studio also for some reason after I set the server clock to get it to connect up properly.

http://social.microsoft.com/Forums/en-US/0ad9a5ee-dcce-4146-a1e6-20eafdccff46/crmsvcutil-error-an-error-occurred-when-verifying-security-for-the-message?forum=crmdevelopment

0
votes

To fully understand your error, you should use config file with enable tracing, here is an example of config file:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="servicecontextname" value="XrmServiceContext"/>
    <add key="codecustomization" value="Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"/>
    <add key="username" value="domain\user"/>
    <add key="password" value="password"/>
    <add key="out" value="XrmEntitiesReference.cs" />
  </appSettings>
  <system.diagnostics>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="configConsoleListener" type="System.Diagnostics.ConsoleTraceListener">
          <filter type="System.Diagnostics.EventTypeFilter" initializeData="Error" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

check out example from here:

http://www.resultondemand.nl/support/sdk/06abab26-40fc-4b85-9a2a-5e68903ea138.htm

0
votes

JIC somebody get the same error.

I made the connection and I were able to generate the context from CRM online. The unique difference is in the URL, I have the next:

https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc

You see this say crm not crm5 but that depends on your organization, to get the rigth one: Open your organization then Settings->Customizations->Developer Resources->Organization data service

My command line to execute CrmSvcUtil.exe is:

CrmSvcUtil.exe    
/url:"https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc"
/out:"E:\Context.cs"
/username:[email protected]
/password:Password

Something else the account should have the required permissions, my account has System Administrator role.

0
votes

I realize this is a long-shot, but has your password changed recently?

With a command string like this, a lot of people use .bat files to automate the process.

I dislike using passwords in .bat files because:

  1. They are not secure (obvious, I know)
  2. Maintenance. Every time you update your password, you would have to remember to update every script. Or painfully troubleshoot every failure and finally remember that the password was embedded.

To mitigate this I use SET with a /P parameter to prompt for a password during .bat file execution.

Not perfect, but a lot better than hard coding a password.

Here is an example using the command string you supplied:

rem ----- begin script -----

SET /P pwd=Password:

CrmSvcUtil.exe /out:E:\OrgXrm.cs /url:https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc /username:[email protected] /password:%pwd%

CLS

SET pwd=.

rem ----- end script -----

In this example the SET /P tells the command processor to set an environment variable and prompt for the input.
“pwd” is the environment variable being set.
“%pwd%” is the actual use of the environment variable.
“Password:” is the prompt string that will be displayed when the .bat file is run.
“CLS” clears the screen.
“pwd=.” sets the environment variable to “.” so the password is not left in the environment.
You can ignore the lines beginning with “rem” as they are simply remarks.

The “not perfect” part of the solution is that your password is visible as you type. However by clearing the screen immediately following the prompt it is cleared from the screen right away. There are other ways to prevent the password from being visible as you type, however I think they are vastly over complicated or require downloading some additional bits. The idea of using a .bat file is that it is quick and easily updatable ergo low maintenance.

The SET /P works well in my case as no one is looking over my shoulder whenever I need to refresh my file, and there is virtually no maintenance once the .bat file is written.