locked
Problem with DateTime ScopeParameters RRS feed

  • Question

  • While trying to use DateTime as ScopeParameters i ran into the exception below:

    System.FormatException occurred
      Message=String was not recognized as a valid DateTime.
      Source=mscorlib
      StackTrace:
           at System.DateTime.Parse(String s, IFormatProvider provider)
      InnerException:

    The cause of it is simple: my client and server have different locale settings (ENU WP7 Emulator vs. German Developer Workstation) and because of this DateTime.Parse fails.

    So whats the suggested workarround? There should be some way to influence the DateTime parsing for the sync service.

     

     

    Monday, August 9, 2010 11:14 AM

Answers

  • What happens is something like this:

    string s = "12/25/2009";
    DateTime dt = (DateTime)Convert.ChangeType(s, typeof(DateTime));
    
    
    Wich wether works or not depending on the system locale you try to run it on.

    • Marked as answer by mjayaram Wednesday, August 11, 2010 5:05 PM
    Tuesday, August 10, 2010 8:19 AM

All replies

  • Can you post the complete stack trace?
    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Monday, August 9, 2010 3:39 PM
  • >	mscorlib.dll!System.DateTime.Parse(string s, System.IFormatProvider provider) + 0xc3 bytes	
     	mscorlib.dll!System.Convert.ToDateTime(string value, System.IFormatProvider provider) + 0xe bytes	
     	mscorlib.dll!System.Convert.ChangeType(object value, System.Type conversionType, System.IFormatProvider provider) + 0x422 bytes	
     	mscorlib.dll!System.Convert.ChangeType(object value, System.Type conversionType) + 0x85 bytes	
     	Microsoft.Synchronization.Services.DLL!Microsoft.Synchronization.Services.WebUtil.ChangeType(object value, System.Type type) + 0x220 bytes	
     	Microsoft.Synchronization.Services.DLL!Microsoft.Synchronization.Services.SyncService<MediFox.mobile4.SyncFx.DefaultScopeOfflineEntities>.InitializeNewClient() + 0x1c6 bytes	
     	Microsoft.Synchronization.Services.DLL!Microsoft.Synchronization.Services.SyncService<MediFox.mobile4.SyncFx.DefaultScopeOfflineEntities>.ProcessRequestForMessage(System.IO.Stream messageBody) + 0x1cc bytes	
     	[Lightweight Function]	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(object instance, object[] inputs, out object[] outputs) + 0x5a5 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x2b5 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0xfd bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x173 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.MessageRpc.Process(bool isOperationContextSet) + 0x17e bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext request, bool cleanThread, System.ServiceModel.OperationContext currentOperationContext) + 0x664 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext request, System.ServiceModel.OperationContext currentOperationContext) + 0x1e3 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult result) + 0x4b bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) + 0x32 bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) + 0x16b bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.AsyncQueueReader.Set(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item) + 0x41 bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item, bool canDispatchOnThisThread) + 0x3d7 bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread) + 0x7e bytes	
     	System.ServiceModel.dll!System.ServiceModel.Channels.SingletonChannelAcceptor<System.ServiceModel.Channels.IReplyChannel,System.ServiceModel.Channels.ReplyChannel,System.ServiceModel.Channels.RequestContext>.Enqueue(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread) + 0x66 bytes	
     	System.ServiceModel.dll!System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(System.ServiceModel.Channels.HttpRequestContext context, System.Action callback) + 0x22e bytes	
     	System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(System.ServiceModel.Activation.HostedHttpRequestAsyncResult result) + 0x168 bytes	
     	System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() + 0x239 bytes	
     	System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() + 0x55 bytes	
     	System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(object state) + 0x53 bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) + 0x71 bytes	
     	System.Runtime.DurableInstancing.dll!System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(uint error, uint bytesRead, System.Threading.NativeOverlapped* nativeOverlapped) + 0x40 bytes	
     	mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) + 0x96 bytes	
     	[Native to Managed Transition]	
     	[Appdomain Transition]	
     	[Native to Managed Transition]	
    

    Tuesday, August 10, 2010 7:42 AM
  • What happens is something like this:

    string s = "12/25/2009";
    DateTime dt = (DateTime)Convert.ChangeType(s, typeof(DateTime));
    
    
    Wich wether works or not depending on the system locale you try to run it on.

    • Marked as answer by mjayaram Wednesday, August 11, 2010 5:05 PM
    Tuesday, August 10, 2010 8:19 AM
  • Thanks for the bug report. I have filed an internal bug and should be fixed in the next release.
    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Tuesday, August 10, 2010 8:32 PM
  • Recently, we began deploying our application internationally and have hit this same issue.  What release includes this fix?  Currently, we are running on MSF 2.0--which works fine for us--but we need this fix for some of our European users.

    Thanks.

     

    Tuesday, June 21, 2011 11:08 AM