B
Bill McCormick
Hello,
Selecting certain rows of data from my WPF datagrid (bound to a
LinqToSQL datasource) are generating exceptions that I'm not sure how to
handle.
It's a FormatException with message: String must be exactly one
character long, but I can't tell what it is about these records that is
causing the problem.
The only info I know how to get is the stack trace (below) and it's not
helping me.
Thanks,
Bill McCormick
--
MSDN Subscriber
System.FormatException was unhandled
Message="String must be exactly one character long."
Source="mscorlib"
StackTrace:
at System.Convert.ToChar(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToChar(IFormatProvider
provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Data.Linq.DBConvert.ChangeType(Object value, Type type)
at Read_Dsp(ObjectMaterializer`1 )
at
System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
at System.Data.Linq.EntitySet`1.Load()
at System.Data.Linq.EntitySet`1.get_Count()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Data.Linq.EntitySet`1.GetNewBindingList()
at
System.Data.Linq.EntitySet`1.System.ComponentModel.IListSource.GetList()
at MS.Internal.Data.ViewManager.GetViewRecord(Object collection,
CollectionViewSource cvs, Type collectionViewType, Boolean createView)
at MS.Internal.Data.DataBindEngine.GetViewRecord(Object
collection, CollectionViewSource key, Type collectionViewType, Boolean
createView)
at
System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object
source, Boolean createView)
at
System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object
source, DependencyObject d)
at
System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
at
System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject
d, DependencyPropertyChangedEventArgs e)
at
System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs
e)
at
System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs
e)
at
System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs
args)
at
System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex
entryIndex, DependencyProperty dp, PropertyMetadata metadata,
EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean
coerceWithDeferredReference, OperationType operationType)
at
System.Windows.StyleHelper.ApplyTemplatedParentValue(DependencyObject
container, FrameworkObject child, Int32 childIndex, FrugalStructList`1&
childRecordFromChildIndex, DependencyProperty dp,
FrameworkElementFactory templateRoot)
at
System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject
container, FrameworkObject child, Int32 childIndex, FrugalStructList`1&
childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory
templateRoot)
at
System.Windows.StyleHelper.LoadOptimizedTemplateContent(DependencyObject
container, ParserContext parserContext, OptimizedTemplateContent
optimizedTemplateContent, FrameworkTemplate frameworkTemplate,
IComponentConnector componentConnector, IStyleConnector styleConnector,
List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
at System.Windows.FrameworkTemplate.LoadContent(DependencyObject
container, List`1 affectedChildren, UncommonField`1
templatedNonFeChildrenField)
at
System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1
dataField, DependencyObject container, FrameworkElementFactory
templateRoot, Int32 lastChildIndex, HybridDictionary
childIndexFromChildID, FrameworkTemplate frameworkTemplate)
at
System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1
templateDataField, FrameworkElement container)
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32
cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at
System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at
System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object
resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object
resizedCompositionTarget)
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object
source, Delegate callback, Object args, Boolean isSingleParameter,
Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate
callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at
System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object
source, Delegate callback, Object args, Boolean isSingleParameter,
Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate
callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at
System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Boolean
isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority
priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame
frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at ScAggScale.App.Main() in C:\ace-co-devel\Aceco32\VS2008\Agg
Load Out\ScAggScale\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Selecting certain rows of data from my WPF datagrid (bound to a
LinqToSQL datasource) are generating exceptions that I'm not sure how to
handle.
It's a FormatException with message: String must be exactly one
character long, but I can't tell what it is about these records that is
causing the problem.
The only info I know how to get is the stack trace (below) and it's not
helping me.
Thanks,
Bill McCormick
--
MSDN Subscriber
System.FormatException was unhandled
Message="String must be exactly one character long."
Source="mscorlib"
StackTrace:
at System.Convert.ToChar(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToChar(IFormatProvider
provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Data.Linq.DBConvert.ChangeType(Object value, Type type)
at Read_Dsp(ObjectMaterializer`1 )
at
System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
at System.Data.Linq.EntitySet`1.Load()
at System.Data.Linq.EntitySet`1.get_Count()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Data.Linq.EntitySet`1.GetNewBindingList()
at
System.Data.Linq.EntitySet`1.System.ComponentModel.IListSource.GetList()
at MS.Internal.Data.ViewManager.GetViewRecord(Object collection,
CollectionViewSource cvs, Type collectionViewType, Boolean createView)
at MS.Internal.Data.DataBindEngine.GetViewRecord(Object
collection, CollectionViewSource key, Type collectionViewType, Boolean
createView)
at
System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object
source, Boolean createView)
at
System.Windows.Data.CollectionViewSource.GetDefaultCollectionView(Object
source, DependencyObject d)
at
System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
at
System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject
d, DependencyPropertyChangedEventArgs e)
at
System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs
e)
at
System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs
e)
at
System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs
args)
at
System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex
entryIndex, DependencyProperty dp, PropertyMetadata metadata,
EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean
coerceWithDeferredReference, OperationType operationType)
at
System.Windows.StyleHelper.ApplyTemplatedParentValue(DependencyObject
container, FrameworkObject child, Int32 childIndex, FrugalStructList`1&
childRecordFromChildIndex, DependencyProperty dp,
FrameworkElementFactory templateRoot)
at
System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject
container, FrameworkObject child, Int32 childIndex, FrugalStructList`1&
childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory
templateRoot)
at
System.Windows.StyleHelper.LoadOptimizedTemplateContent(DependencyObject
container, ParserContext parserContext, OptimizedTemplateContent
optimizedTemplateContent, FrameworkTemplate frameworkTemplate,
IComponentConnector componentConnector, IStyleConnector styleConnector,
List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
at System.Windows.FrameworkTemplate.LoadContent(DependencyObject
container, List`1 affectedChildren, UncommonField`1
templatedNonFeChildrenField)
at
System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1
dataField, DependencyObject container, FrameworkElementFactory
templateRoot, Int32 lastChildIndex, HybridDictionary
childIndexFromChildID, FrameworkTemplate frameworkTemplate)
at
System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1
templateDataField, FrameworkElement container)
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32
cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at
System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at
System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object
resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object
resizedCompositionTarget)
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object
source, Delegate callback, Object args, Boolean isSingleParameter,
Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate
callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at
System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object
source, Delegate callback, Object args, Boolean isSingleParameter,
Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate
callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at
System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Boolean
isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority
priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame
frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at ScAggScale.App.Main() in C:\ace-co-devel\Aceco32\VS2008\Agg
Load Out\ScAggScale\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: