Solved

Input String was not in the correct format - Strange places

Posted on 2007-11-29
8
451 Views
Last Modified: 2013-11-07
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

0
Comment
Question by:traxion
  • 4
  • 3
8 Comments
 
LVL 9

Author Comment

by:traxion
Comment Utility
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

 
0
 
LVL 21

Expert Comment

by:surajguptha
Comment Utility
>>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
0
 
LVL 3

Expert Comment

by:bnaveke
Comment Utility
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.
0
 
LVL 9

Author Comment

by:traxion
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 21

Expert Comment

by:surajguptha
Comment Utility
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
0
 
LVL 9

Author Comment

by:traxion
Comment Utility
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

0
 
LVL 21

Accepted Solution

by:
surajguptha earned 500 total points
Comment Utility
>>'SEM5.SEM5.SEMSection' to type 'SEM5.SEM5.SEMSection'. clearly indicates that you might be using two different assemblies for SEMSection and when the SEMSection object made using one assemblty is type casted using SEMSection from another namespace it creates the problem
0
 
LVL 9

Author Comment

by:traxion
Comment Utility
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.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now