我试图使用C#CloseQuoteRequest在MSCRM中关闭引用 .
CloseQuoteRequest closeQuoteRequest = new CloseQuoteRequest()
{
QuoteClose = new QuoteClose()
{
QuoteId = quote.ToEntityReference(),
Subject = "Quote Close " + DateTime.Now.ToString(),
},
Status = new OptionSetValue(-1),
RequestName = "CloseQuote",
};
Service.Execute(closeQuoteRequest);
我收到了错误;
格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://schemas.microsoft.com/xrm/2011/Contracts/Services:request时出错 . InnerException消息是'第1行位置错误711.元素'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value'包含来自映射到名称'CRM.Entities的类型的数据.Entities:QuoteClose” . 反序列化器不知道映射到此名称的任何类型 . 考虑更改DataContractResolver上的ResolveName方法的实现,以返回名称'QuoteClose'和名称空间'CRM.Entities.Entities'的非空值 . ' . 有关更多详细信息,请参阅InnerException .
我没有内心的例外 .
2 回答
我不知道为什么会这样,但是在QuoteClose Entity中添加了.ToEntity() .
来自MSDN的代码示例没有设置
RequestName = "CloseQuote"
属性,因为它不需要 . 去掉它 .