Invalid cast from 'System.DateTime' to 'Csla.SmartDate' when debugging

Invalid cast from 'System.DateTime' to 'Csla.SmartDate' when debugging

Old forum URL: forums.lhotka.net/forums/t/8992.aspx


MikeGoldsmith posted on Wednesday, May 26, 2010

Hello all

I've recently upgraded my workstation from Vista to Windows 7 Enterprise and all seemed to have gone well. Projects build fine but am not experiencing an odd error when trying to debug our IIS hosted application locally. The app build and works as expected but when attaching to the IIS process (w3wp.exe) no symbols are loaded then when server processing is started an invalid cast exception is generated (see below).

Stack trace:

System.InvalidCastException occurred

  Message="Invalid cast from 'System.DateTime' to 'Csla.SmartDate'."

  Source="mscorlib"

  StackTrace:

       at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)

       at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider)

       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)

       at System.Convert.ChangeType(Object value, Type conversionType)

       at Csla.Utilities.CoerceValue(Type desiredType, Type valueType, Object oldValue, Object value) in C:\Documents\Communicator\Trunk\Csla\Utilities.cs:line 191

  InnerException: (None)

I'm really stuggling to figure out whats happening as it isn't happening on my colleagues machines who are still running Vista.

My setup:

Windows 7 Enterprise
Visual Studio 2008
IIS 6.1
CSLA 3.8
.Net 2, 3, 3.5 and 4.0 installed 

Any suggestions / pointers?

Thanks,
Mike 

MikeGoldsmith replied on Wednesday, May 26, 2010

The line that the exception is thrown is 191 in Utilities.cs

          return Convert.ChangeType(value, desiredType); 

RockfordLhotka replied on Wednesday, May 26, 2010

What is your line of code that triggers this? Is it a SetProperty() call?

Copyright (c) Marimer LLC