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.Enabl eCaching 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.GetCom munitiesBy User(Membe rship.GetU ser().User Name)
If cList.Count > 0 Then
For Each comm As Community.Community In cList
result += CInt(SiteProvider.CallLog. GetCallVol ume(sDate, eDate, comm.TableName))
Next
End If
Else
Dim tableName As String = Community.Community.GetTab leNameFrom CommunityI d(commId)
result += CInt(SiteProvider.CallLog. GetCallVol ume(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.Enabl
result = CInt(BizObject.Cache(key))
Else
If commId = 0 Then
Dim cList As List(Of Community.Community) = Community.Community.GetCom
If cList.Count > 0 Then
For Each comm As Community.Community In cList
result += CInt(SiteProvider.CallLog.
Next
End If
Else
Dim tableName As String = Community.Community.GetTab
result += CInt(SiteProvider.CallLog.
End If
BaseCallLog.CacheData(key,
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
>>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
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.
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.
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.Comp
Microsoft.VisualBasic.Comp
[InvalidCastException: Conversion from string "GetTotalCalls_" to type 'Double' is not valid.]
Microsoft.VisualBasic.Comp
Microsoft.VisualBasic.Comp
SEM5.SEM5.BLL.CallLog.Call
SEM.Members_Client_Default
SEM.Members_Client_Default
System.Web.Util.CalliHelpe
System.Web.Util.CalliEvent
System.EventHandler.Invoke
System.Web.UI.Control.OnLo
System.Web.UI.Control.Load
System.Web.UI.Page.Process