简体   繁体   English

Dynamics CRM 2011

[英]Dynamics CRM 2011

I am new to Dynamics CRM 2011 Online. 我是Dynamics CRM 2011 Online的新手。 I am try to generate the data context class using CrmSvcUtil.exe 我尝试使用CrmSvcUtil.exe生成数据上下文类

This is my command: 这是我的命令:

CrmSvcUtil.exe /out:E:\OrgXrm.cs
/url:https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc
/username:MDTest@MDTestUser.onmicrosoft.com /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. CrmSvcUtil.exe错误:0:由于异常而退出程序,退出代码为2:Sy stem.ServiceModel.FaultException:验证消息的安全性时发生错误。

I was researching another issue when I ran across a post in the Microsoft forums that may help. 当我在Microsoft论坛上遇到可能有帮助的帖子时,我正在研究另一个问题。 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. 在我的客户端计算机上,设置服务器时钟以使其正确连接后,由于某种原因,我还必须重新启动Visual Studio。

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 http://social.microsoft.com/Forums/zh-CN/0ad9a5ee-dcce-4146-a1e6-20eafdccff46/crmsvcutil-error-an-error-occurred-when-verifying-security-for-the-message?forum=企业发展

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 http://www.resultondemand.nl/support/sdk/06abab26-40fc-4b85-9a2a-5e68903ea138.htm

JIC somebody get the same error. JIC有人遇到相同的错误。

I made the connection and I were able to generate the context from CRM online. 我建立了连接,并且能够从CRM联机生成上下文。 The unique difference is in the URL, I have the next: 唯一的区别是URL,接下来是:

https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc 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 您会看到说的是crm而不是crm5,但这要取决于您的组织, 这才是最严格的 :打开组织,然后依次单击 设置 -> 定制 -> 开发人员资源 -> 组织数据服务

My command line to execute CrmSvcUtil.exe is: 我执行CrmSvcUtil.exe的命令行是:

CrmSvcUtil.exe    
/url:"https://architecture2.api.crm.dynamics.com/XRMServices/2011/Organization.svc"
/out:"E:\Context.cs"
/username:MyUser@architecture2.onmicrosoft.com
/password:Password

Something else the account should have the required permissions, my account has System Administrator role. 该帐户应具有其他权限,我的帐户具有系统管理员角色。

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. 使用这样的命令字符串,许多人使用.bat文件来自动化该过程。

I dislike using passwords in .bat files because: 我不喜欢在.bat文件中使用密码,因为:

  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. 为了减轻这种情况,我在/ bat参数中使用SET来在.bat文件执行过程中提示输入密码。

Not perfect, but a lot better than hard coding a password. 并不完美,但是比硬编码密码要好得多。

Here is an example using the command string you supplied: 这是使用您提供的命令字符串的示例:

rem ----- begin script ----- rem -----开始脚本-----

SET /P pwd=Password: SET / P pwd =密码:

CrmSvcUtil.exe /out:E:\\OrgXrm.cs /url: https://mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc /username:MDTest@MDTestUser.onmicrosoft.com /password: %pwd% CrmSvcUtil.exe /out:E:\\OrgXrm.cs / url: https: //mdtestuser.api.crm5.dynamics.com/XRMServices/2011/Organization.svc /用户名:MDTest@MDTestUser.onmicrosoft.com / password: % pwd%

CLS CLS

SET pwd=. 设置pwd =。

rem ----- end script ----- 雷姆-----结束脚本-----

In this example the SET /P tells the command processor to set an environment variable and prompt for the input. 在此示例中,SET / P告诉命令处理器设置环境变量并提示输入。
“pwd” is the environment variable being set. “ pwd”是要设置的环境变量。
“%pwd%” is the actual use of the environment variable. “%pwd%”是环境变量的实际使用。
“Password:” is the prompt string that will be displayed when the .bat file is run. “密码:”是运行.bat文件时将显示的提示字符串。
“CLS” clears the screen. “ CLS”清除屏幕。
“pwd=.” sets the environment variable to “.” so the password is not left in the environment. “ pwd =。”将环境变量设置为“。”,因此密码不会留在环境中。
You can ignore the lines beginning with “rem” as they are simply remarks. 您可以忽略以“ rem”开头的行,因为它们只是注释。

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. 使用.bat文件的想法是它可以快速,轻松地更新ergo低维护成本。

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. SET / P在我的情况下效果很好,因为每当我需要刷新文件时,没人会抬头,而且一旦写入.bat文件,几乎不需要维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM