Frustrating issue deploying an application in Release mode

Frustrating issue deploying an application in Release mode

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


gderoeck posted on Tuesday, August 21, 2007

Hello,

This may not be a CSLA issue, but I thought I'd ask just in case........

I have a page that works fine in debug mode but then fails with the error below in Release mode:

DataPortal.Fetch failed (System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
   at System.Data.SqlClient.SqlBuffer.get_String()
   at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
   at Csla.Data.SafeDataReader.GetString(Int32 i) in C:\Visual Studio 2005\Projects\csla20vb2\csla20vb\Csla\Data\SafeDataReader.vb:line 48
   at Csla.Data.SafeDataReader.GetString(String name) in C:\Visual Studio 2005\Projects\csla20vb2\csla20vb\Csla\Data\SafeDataReader.vb:line 61
   at AMCSLAHangerLib.PilotInfo.PilotInformation.DataPortal_Fetch(Criteria criteria))

This occurs when a user clicks a tree node, calling a GetObject method from an Editable Root object.  The web project references a class library in the same solution.  Like I said, it works fine in debug mode.  I'm using VS2005 and CSLA v2.1.4.

I've tried to solve the issue by reloading and re-referencing the CSLA dll in the class library as well as re-referencing the class library from the web project.  Nothing seems to work and gives me the same error every time.

Any insight would be appreciated.  Thank you!

juddaman replied on Tuesday, August 21, 2007

Hi

Probably an obvious point but are you using the same database for debug and release?

George

GaltSalt replied on Tuesday, August 21, 2007

You probably have strict on in release mode.

without it, there's an implicit convertion between one of your AMCSLAHangerLib.PilotInfo.PilotInformation columns that you think is a string. It's not. It's an integer. Turn strict on in debug mode, temporarily put a try catch around your dr read and walk through your fetch for that object and you'll see which one is really an int rather than a string.

gderoeck replied on Tuesday, August 21, 2007

Robert,

Thank you for the response - I would like to try that, but how do you turn strict on and off?

George - the database isn't even being hit.  It's failing before the fetch function in the class is being reached.

Thanks again for any input.

GaltSalt replied on Wednesday, August 22, 2007

In your project's cofig pages in Visual Studio...what verision do you have?

I think in both, if you right click on the project in the solution explorer, select properties, then select the tab for compile or build options, you'll see either a drop down or checkbox for strict option. You can also define it in Code at the top of your file (the very first line!)

Option Strict On 

Copyright (c) Marimer LLC