Link to home
Start Free TrialLog in
Avatar of traxion
traxion

asked on

Input String was not in the correct format - Strange places

I am getting a very very odd error.  I have a web application that was painstakingly converted from C# to VB .NET.  Now I know there is a lot of work involved to getting this to function, but I'm seeing some strange errors.  I have a function that is giving me the "Input string was not in hte correct format" error, however, it does it on odd lines.  In the Attached snippet, the error is on the last "End If" line.  If I comment the whole block out and try to manually return an integer, it will throw the error on one of my commented lines.  The code is below (not sure how the snippet system works yet).  Also, this is .NET Framework 2.0.  Compiles with no errors or warnings.

            Dim result As Integer = 0

            Dim key As String = "GetTotalCalls_" & commId & "_" & sDate.ToShortDateString() & "_" & eDate.ToShortDateString()
            If BaseCallLog.Settings.EnableCaching AndAlso BizObject.Cache(key) IsNot Nothing Then
                result = CInt(BizObject.Cache(key))
            Else
                If commId = 0 Then
                    Dim cList As List(Of Community.Community) = Community.Community.GetCommunitiesByUser(Membership.GetUser().UserName)
                    If cList.Count > 0 Then
                        For Each comm As Community.Community In cList
                            result += CInt(SiteProvider.CallLog.GetCallVolume(sDate, eDate, comm.TableName))
                        Next
                    End If
                Else
                    Dim tableName As String = Community.Community.GetTableNameFromCommunityId(commId)
                    result += CInt(SiteProvider.CallLog.GetCallVolume(sDate, eDate, tableName))
                End If
                BaseCallLog.CacheData(key, result)
            End If
            Return result
Dim result As Integer = 0
 
            Dim key As String = "GetTotalCalls_" & commId & "_" & sDate.ToShortDateString() & "_" & eDate.ToShortDateString()
            If BaseCallLog.Settings.EnableCaching AndAlso BizObject.Cache(key) IsNot Nothing Then
                result = CInt(BizObject.Cache(key))
            Else
                If commId = 0 Then
                    Dim cList As List(Of Community.Community) = Community.Community.GetCommunitiesByUser(Membership.GetUser().UserName)
                    If cList.Count > 0 Then
                        For Each comm As Community.Community In cList
                            result += CInt(SiteProvider.CallLog.GetCallVolume(sDate, eDate, comm.TableName))
                        Next
                    End If
                Else
                    Dim tableName As String = Community.Community.GetTableNameFromCommunityId(commId)
                    result += CInt(SiteProvider.CallLog.GetCallVolume(sDate, eDate, tableName))
                End If
                BaseCallLog.CacheData(key, result)
            End If
            Return result

Open in new window

Avatar of traxion
traxion

ASKER

Here's hte Stack Trace:

[FormatException: Input string was not in a correct format.]
   Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +211
   Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +74

[InvalidCastException: Conversion from string "GetTotalCalls_" to type 'Double' is not valid.]
   Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) +218
   Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value) +6
   SEM5.SEM5.BLL.CallLog.CallLog.GetTotalCalls(Int32 commId, DateTime sDate, DateTime eDate) in D:\DEV\ArialObjects\ObjectsBinary\SEM5\BLL\CallLog\CallLog.vb:249
   SEM.Members_Client_Default.UpdateStatLabels() in D:\DEV\Arial VB Final\AVB\Members\Client\Default.aspx.vb:69
   SEM.Members_Client_Default.Page_Load(Object sender, EventArgs e) in D:\DEV\Arial VB Final\AVB\Members\Client\Default.aspx.vb:48
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

 
>>If I comment the whole block out and try to manually return an integer, it will throw the error on one of my commented lines.

This indicates that your latest code isnt deployed on the web server you are trying to debug. Try commenting your code and then deploying it again afresh and see if this happens again
Check the value of commId.  If it is Null or Empty it may through this error. Then check this condition on other variables including any that are getting passed in.
Avatar of traxion

ASKER

Ok...the web server is local on my machine...I have code in two assemblies, both in hte same solution, but recompiled and deployed.  This is a "Web application".

Also, just for the heck of it, I changed the function definition and made all values it accepts "Optionals" with a default value.  I then commented everything and added the line "Return 5" to return an integer value of 5.  My commented lines were then throwing the error.
Can you debug line by line to check if the debug actually executes the commented lines? I am just trying to make sure that it isnt the old uncommented code that is being execute because of some strange reason
Avatar of traxion

ASKER

Well...I may have solved the issue.  I had two projects in hte same solution.  Both projects had hte same namespace but also the same assembly name and were stepping on eachother.  Now that I have the projects debugged, I merged the files into a single project and updated my references.  This is the way the application was originally, but there were two many errors to debug after the translation so I separatd the Bus. Logic and Data Access layers into a separate assembly.  Once I changed the assembly name of the layered project, it fixed the problem...so I have merged into a single assembly now and am dealing with a different error.  Thanks for everyone's help.  I'd still like ot assign points, so I'll show you my resulting error:


Private Sub New()
Line 9:  		End Sub
Line 10:         Public Shared ReadOnly Settings As SEMSection = DirectCast(WebConfigurationManager.GetSection("SEMv5"), SEMSection)
Line 11: 	End Class
Line 12: End Namespace
 
 
Source File: D:\DEV\Arial VB Final\AVB\nTierObjects\Globals.vb    Line: 10 
 
Stack Trace: 
 
 
[InvalidCastException: Unable to cast object of type 'SEM5.SEM5.SEMSection' to type 'SEM5.SEM5.SEMSection'.]
   SEM5.SEM5.Globals..cctor() in D:\DEV\Arial VB Final\AVB\nTierObjects\Globals.vb:10
 
[TypeInitializationException: The type initializer for 'SEM5.SEM5.Globals' threw an exception.]
   SEM5.SEM5.BLL.Community.BaseCommunity.get_Settings() in D:\DEV\Arial VB Final\AVB\nTierObjects\BLL\Community\BaseCommunity.vb:12
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of traxion

ASKER

surajquptha - you nailed it. ;)  I actually had figured it out just before reading your post.  I was still referencing the old assembly.  Cleaned up the folders, fixed the assembly name, and away we go.  The application is now functional.  Thanks!  Full points awarded.