Показать сообщение отдельно
Старый 12.12.2012, 12:27   #6  
Konstantin Katsovich is offline
Konstantin Katsovich
Участник
Аватар для Konstantin Katsovich
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
 
243 / 57 (2) ++++
Регистрация: 22.10.2008
Адрес: Israel
Цитата:
Сообщение от ma-lex Посмотреть сообщение
Доброе время суток уважаемые форумчане. Обращаюсь к Вам с такой проблемой. Раз в сутки выполняется консольное приложение, которое обновляет данные в CRM (2011). Код примерно такой:
X++:
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
Uri uri = new Uri("http://localhost:5555/rbrcrm/XRMServices/2011/Organization.svc");
OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credentials, null);
// This statement is required to enable early-bound type support.
proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
IOrganizationService service = (IOrganizationService)proxy;
...
Entity vCon = new Entity("contact");
...
service.Update(vCon);
...
service.Update(vCon) - выполняется в цикле.

Приложение обычно выполняется около 3х часов. Примерно в 70% программа вылетает с ошибкой, спустя значительное время после выполнения, на строке service.Update(vCon);
Причем, судя по логам, программа пытается выполнить эту строчку минут 30-40, потом выходит сообщение об ошибке:

X++:
System.ServiceModel.Security.MessageSecurityException:            .     .  . ---> System.ServiceModel.FaultException:        .    .
 ---      ---

Server stack trace: 
    System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
    System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    Microsoft.Xrm.Sdk.IOrganizationService.Update(Entity entity)
    Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.UpdateCore(Entity entity)
Есть дни, когда весь процесс проходит без ошибок (около 30%).
Прошу помощи в решении проблемы.

Для начала вам нужно посмотреть внутреннее исключение как написано в сообщение.
От неё и надо отталкиваться.

У меня тоже появляется похожая ошибка, в Windows Services.
Код:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

Server stack trace: 
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Моё внутренне исключение такое.
Код:
Inner Exception:
The security context token is expired or is not valid. The message was not processed.
А что у Вас?

В трайсе CRM я ни чего не нашел на эту тему.
Судя по стэк трейсу эта ошибка возникает еще до попадания в CRM. (то есть в .net)

Опытных путем было установлено, что у меня это происходит только в том случае, если я начинаю использовать больше одного процесса в App Pool.
Когда ставишь один процесс ошибка пропадает. так и живу пока.


Так же мной было опробовано два решения, но для меня безрезультатно.
http://rajeevpentyala.wordpress.com/...local_machine/

http://pragmatismismymethodology.blo...exception.html

Удачи.
__________________
Читайте SDK!!!