【发布时间】:2011-11-21 11:44:22
【问题描述】:
我们有一个安装程序 (vdproj msi),它使用 OrganizationServiceProxy 安装 Dynamics 2011 受管软件包(存储为嵌入式资源的 zip 文件)。它按如下方式构造了 OrganizationServiceProxy:
var organizationUri = new Uri(string.Format(
ORGANIZATION_SERVICE_URI_TEMPLATE, configuration.WebServiceUrl,
configuration.CrmOrganizationName));
var credentials = new ClientCredentials();
credentials.Windows.ClientCredential = GetNetworkCredentials();
credentials.UserName.UserName = credentials.Windows.ClientCredential.UserName;
credentials.UserName.Password = credentials.Windows.ClientCredential.Password;
var client = new OrganizationServiceProxy(organizationUri, null, credentials, null)
{ Timeout = TimeSpan.FromMilliseconds(WEB_SERVICE_TIMEOUT) };
return client;
并执行 ImportSolutionRequest
var importSolutionRequest = new ImportSolutionRequest
{
CustomizationFile = Resources.DynamicsSolution,
ImportJobId = Guid.NewGuid()
};
service.Execute(importSolutionRequest);
这会产生非常模糊的错误:
Web Service 插件在 OrganizationId 中失败:510c06a3-6ee9-43a7-ba54-677054348813; SdkMessageProcessingStepId:1b830950-e106-4ee1-b3fd-d348cb65dc8d;实体名称:无;阶段:30;消息名称:ImportSolution;程序集名称:Microsoft.Crm.Extensibility.InternalOperationPlugin,Microsoft.Crm.ObjectModel,版本=5.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35;类名:Microsoft.Crm.Extensibility.InternalOperationPlugin;异常:未处理的异常:System.Reflection.TargetInvocationException:调用的目标已引发异常。 在 System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo 方法,对象目标,Object[] 参数,SignatureStruct& sig,MethodAttributes methodAttributes,RuntimeType typeOwner) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] 参数,CultureInfo 文化,布尔型 skipVisibilityChecks) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] 参数,CultureInfo 文化) 在 System.Web.Services.Protocols.LogicalMethodInfo.Invoke(对象目标,对象 [] 值) 在 Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider 服务提供者) 在 Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext 上下文) 在 Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext 上下文) 内部异常:System.Globalization.CultureNotFoundException:不支持文化。 参数名称:文化 0 (0x0000) 是无效的区域性标识符。 在 System.Globalization.CultureInfo.InitializeFromCultureId(Int32 文化,布尔值 useUserOverride) 在 Microsoft.Crm.Tools.ImportExportPublish.SolutionPackageUpgrade..ctor(ExecutionContext 上下文) 在 Microsoft.Crm.Tools.ImportExportPublish.RootImportHandler..ctor(ImportXml 父级,布尔覆盖 UnmanagedCustomizations,布尔 publishWorkflows,字节 [] 压缩自定义文件,布尔设置,现有数据库版本,ExecutionContext 上下文,布尔提取所有文件) 在 Microsoft.Crm.Tools.ImportExportPublish.ImportXml..ctor(布尔覆盖UnmanagedCustomizations,布尔publishWorkflows,字节[]压缩自定义文件,Guid importJobId,布尔convertToManaged,ExecutionContext上下文) 在 Microsoft.Crm.WebServices.ImportXmlService.ImportSolution(Boolean overwriteUnmanagedCustomizations, Boolean publishWorkflows, Byte[] customizeFile, Guid importJobId, Boolean convertToManaged, ExecutionContext context)
经过几个小时的研究和反汇编 Microsoft Dynamics 内部 dll(如果我需要这样做不是很伤心的话会很有趣),我发现传入请求的 ExecutionContext 中的 CallerId 是空的(即使请求使用提供的凭据正确验证)。
所以,我从 SystemUser 表中查找了我想使用的 SystemUserId 并指定了
client.CallerId = Guid.Parse("94DB2FFC-DBDE-E011-95D5-005056AF0052");
你瞧,ImportSolutionRequest 在执行此操作后成功了。
剩下的问题是:
- 是否有另一种方法可以在不指定实际有效的 CallerId 的情况下完成这个荒谬的基本任务?为什么没有它就不能工作?
- 如果没有,我如何根据我提供的凭据在 OrganizationServiceProxy 上设置 callerId(无需硬编码)。
- 为什么我在全新服务器上全新、完全默认安装 Dynamics 时会出现这些问题?
【问题讨论】:
标签: .net dynamics-crm dynamics-crm-2011