dpss
Nuker Posts:17
|
09/27/2010 4:59 AM |
|
I've just upgraded to DNN 5.5.1 and my custom module is now broken. I receive the following error: "DotNetNuke.Services.Exceptions.ModuleLoadException: Invalid cast from 'System.Int32' to 'System.Nullable` " . This happens when my custom module interacts with a database which has nullable fields
My custom module is using an info class with a nullable fields, which is supposed to get hydrated using the CBO.FillCollection method from a controller class. This worked in the previous version 5.1.4, but now, after the upgrade to 5.5.1, I'm receiving these cast errors.
Am I doing something wrong here or is this some kind of bug? |
|
|
|
|
Joseph Craig DNN MVP Posts:11667
|
09/27/2010 7:24 AM |
|
Does the custom module use it's own data table, or is it reading from a DotNetNuke table? Did the table change between the two versions? |
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
dpss
Nuker Posts:17
|
09/27/2010 7:57 AM |
|
The custom module is using its own data table. In fact its communicating with a different database all together. The same module works perfectly fine in DNN 5.1.4. Its only when we upgrade to 5.5.1 that we get the error shown below.The issue seems to be with the method calls of DotNetNuke.Common.Utilities.CBO " DotNetNuke.Services.Exceptions.ModuleLoadException: Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'. ---> System.InvalidCastException: Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at System.Int32.System.IConvertible.ToType(Type type, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at DotNetNuke.Common.Utilities.CBO.HydrateObject(Object hydratedObject, IDataReader dr) at DotNetNuke.Common.Utilities.CBO.FillObjectFromReader(Object objObject, IDataReader dr) at DotNetNuke.Common.Utilities.CBO.CreateObjectFromReader(Type objType, IDataReader dr, Boolean closeReader) at DotNetNuke.Common.Utilities.CBO.FillListFromReader[TItem](IDataReader dr, IList`1 objList, Boolean closeReader) at DotNetNuke.Common.Utilities.CBO.FillCollection[TItem](IDataReader dr) " |
|
|
|
|
c g
Nuke Newbie Posts:4
|
08/03/2011 3:37 PM |
|
Did anyone find a solution for this problem? I upgraded from 5.1.2 to 5.6.3 and now I'm getting the same error. |
|
|
|
|
Joseph Craig DNN MVP Posts:11667
|
08/03/2011 3:57 PM |
|
Could you copy and paste the error message? Are you using a custom module? |
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
c g
Nuke Newbie Posts:4
|
08/11/2011 12:29 PM |
|
Joseph, Yes, we're using a custom module. Here's the stack trace: DotNetNuke.Services.Exceptions.PageLoadException: Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'. ---> System.InvalidCastException: Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'. at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) at System.Int32.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 DotNetNuke.Common.Utilities.CBO.HydrateObject(Object hydratedObject, IDataReader dr) at DotNetNuke.Common.Utilities.CBO.FillObjectFromReader(Object objObject, IDataReader dr) at DotNetNuke.Common.Utilities.CBO.CreateObjectFromReader(Type objType, IDataReader dr, Boolean closeReader) at DotNetNuke.Common.Utilities.CBO.FillObject(IDataReader dr, Type objType) at LossPrevention.IM_Initiative.Components.InitiativeController.GetInitiative(Int32 initiativeId) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\Components\InitiativeController.cs:line 31 at LossPrevention.IM_Initiative.ViewInitiative.LoadInitiativeInfo(Int32 initiativeId) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\ViewInitiative.ascx.cs:line 406 at LossPrevention.IM_Initiative.ViewInitiative.Page_Load(Object sender, EventArgs e) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\ViewInitiative.ascx.cs:line 43 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Best, Chris
|
|
|
|
|
Joseph Craig DNN MVP Posts:11667
|
08/11/2011 12:42 PM |
|
Reformatting things a bit you'll see that the basic error is: Invalid cast from 'System.Int32' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' And that this is located: at LossPrevention.IM_Initiative.Components.InitiativeController.GetInitiative(Int32 initiativeId) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\Components\InitiativeController.cs:line 31 at LossPrevention.IM_Initiative.ViewInitiative.LoadInitiativeInfo(Int32 initiativeId) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\ViewInitiative.ascx.cs:line 406 at LossPrevention.IM_Initiative.ViewInitiative.Page_Load(Object sender, EventArgs e) in C:\Development\ReportNet_DNN\DesktopModules\IM_Initiative\ViewInitiative.ascx.cs:line 43 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) where there is a call to: DotNetNuke.Common.Utilities.CBO.FillObject(IDataReader dr, Type objType) ------- Without seeing the code, it looks like you are using a wrong type in there. The best way to deal with this is to debug the module using Visual Studio. You should be able to step into the module and examine the variable just before this error is thrown. Presumable something changed between the two versions of DotNetNuke.
|
|
Joe Craig, Patapsco Research Group Complete DNN Support |
|
|
c g
Nuke Newbie Posts:4
|
08/11/2011 1:28 PM |
|
The code worked in the previous version of DNN. What happened is that DNN changed the CBO utility so that it handles null values differently now. I'm hoping for a work around that will allow us to avoid having to rewrite all of our modules... |
|
|
|
|
Joseph Craig DNN MVP Posts:11667
|
|
c g
Nuke Newbie Posts:4
|
08/11/2011 1:44 PM |
|
Thanks. I've seen that post (and several others now) that all suggest using IHydratable. I was trying to avoid doing that because it will require a significant amount of coding given the number of classes that will need to change. For anyone else looking into this issue, I just found that it's reported as a bug, but as of today is not being worked on: http://support.dotnetnuke.com/issue...1&PROJID=2 |
|
|
|
|