473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bogus System.ArgumentException has me puzzled

Hi,

I have an app that is crashing due to a System.ArgumentException. At this
point it's just a simple app to test some basic object values. The main app
is a Windows App that looks like this.

Public Class DesTestForm

Private Sub DesTestForm_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim x As DFTypeTests = New DFTypeTests()
x.DFTypesTestSetup()
Try
x.Test001DFTypesListRead()
Catch ex As Exception
Dim i As Integer = 5
End Try

End Sub
End Class

This "form" is the startup form. So the OnLoad code runs when I start
debugging. I've single stepped through the code called by
x.DFTypesTestSetup() and it's OK. The exception occurs when
x.Test001DFTypesListRead() is run. Using "Step Into" on that line
immediately takes me to the Catch block.

ex.Message is {"Value does not fall within the expected range."}
ex.Data.Item is " In order to evaluate an indexed property, the property
must be qualified and the arguments must be explicitly supplied by the user."
ex.StackTrace correctly shows Test001DFTypesListRead() as the last call.

The code being called is in a separate Class Library project in the same
Solution...

Public Class DFTypeTests
Dim a As Boolean
Dim types As DFTypesList
Dim t As DFType

Public Sub DFTypesTestSetup()
ScenarioManager.SetScenario(3)
BPPrincipal.Logout()
a = BPPrincipal.Login("MTwain", "pw")
End Sub

Public Sub Test001DFTypesListRead()
' Read the Scenario 3 DFTypesList
' Test the contents of the first and last object in the list

' Get the DFTypesList
<Do some tests>...
End Sub

Nothing in Test001DFTypesListRead() ever runs. The exception occurs
immediately on the call to Test001DFTypesListRead() from the Form.Load
handler.

Apparently, the compiler is interpreting the call as an attempt to read an
indexed property and crashes because there's no argument?

However, the TargetSite MemberType property of the exception correctly
identifies the TargetSite as a "Method{8}"

I don't think I have any code access problems because the call to
DFTypesTestSetup() works.

Any suggestions are appreciated.

Thanks.

BBM
Jan 7 '07 #1
6 2808
Hi BBM,

Based on my understanding, your .Net Winforma application is throwing
ArgumentException while executing a method, however, based on the code
review you can not understand why ArgumentException occurs, so you want to
find a way to identify the root cause of the ArgumentException.

First, can you tell me what version of debugger you are using, VS.net2003
or VS2005? I assume VS2005 now.

To accurately locate the code block generates the exception, you need
configure the debugger for 2 things:
1. Correctly load symbols for all modules/assemblies in your application.
This is because the exception may be thrown by some .Net BCL code(not your
written code), you need the symbol for various BCL assemblies.
2. Debuggers are passed 2 notifications during one exception: first chance
and second chance. The first chance notification is passed to your debugger
immediately when the code generates the exception, so this is what you
want. If your debuggers ignore the first chance exception, the OS/CLR will
only display a text to the "Output" window and call the "Catch ex As
Exception" you provided. If no "Catch ex As Exception" for this exception
is found, the debugger will finally be passed second chance exception
notification.

For #1, to set the symbol server path in VS2005, you should input
"srv*c:\LocalSymbols*http://msdl.microsoft.com/download/symbols;" in the
Tools | Options | Debugging | Symbols as the directory. This will tell the
VS2005 debugger to lookup symbol from the Microsoft symbol server
"http://msdl.microsoft.com/download/symbols" and cache the downloaded
symbol in "c:\LocalSymbols" folder.

Additionally, there is a new feature named "Just My Code" which is enabled
by default in VS2005. This means that VS2005 will not load symbol for
non-user code assemblies, such as all .Net BCL assemblies. So you should
disable this "Just My Code" feature from Tools | Options | Debugging, and
uncheck "Enable Just My Code" check box.(the VS2005 IDE maybe need
close&re-open to enable the setting)

Below link contains more information regarding JMC feature:
"Is 'Just my Code' for you?"
http://blogs.msdn.com/greggm/archive...29/201315.aspx

To verify if the above 2 settings take effect, you may open "Module" window
after launching the application under debugger.

Note: symbol loading may require some time after you pressed F5, you may
check the "Output" window to verify the symbol loading process for each
modules.

For #2, you may open "Debug"->"Exceptions..." dialog, expand and find
"Common Language Runtime Exceptions" ->"System"->"System.ArgumentException"
node in the dialog. you should check the "Thrown" checkbox in the right and
click Ok. This tells the debugger to report the first chance exception to
the end user. Then you may open the "Call Stack" window to see the deepest
function frame for this exception.

Note: since you do not have the source code of .Net assemblies, debugger
may require you to open the "Disassembly" window for the exception code
location.

If you still have problem of locating the code accurately, I recommend you
create a little reproduce sample, I will give it a troubleshoot.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 8 '07 #2
Hi Jeffrey,

1) I'm using the VS 2005 de-bugger.
2) The output window says that ex (from the Catch block in my original
message IS a first chance exception.
3) I turned off "Just my code" and ran the program in the de-bugger. Same
results as originally reported.
4) I loaded the symbols for the BCL code as you suggested. (Note: in VS
2005 you put the URL in the top text box area - after clicking on the
"folder" icon. Then you have to create the "C:\LocalSymbols folder and set
it as the cache directory in a separate textbox).
5) I ran the progam in the debugger again. Output window says all symbols
loaded. Same results from debugging session.

The code behind the simple test code is somewhat involved so it's difficult
to send a "real" sample (SQL databases involved). Do you have any other
suggestions?

BBM
""Jeffrey Tan[MSFT]"" wrote:
Hi BBM,

Based on my understanding, your .Net Winforma application is throwing
ArgumentException while executing a method, however, based on the code
review you can not understand why ArgumentException occurs, so you want to
find a way to identify the root cause of the ArgumentException.

First, can you tell me what version of debugger you are using, VS.net2003
or VS2005? I assume VS2005 now.

To accurately locate the code block generates the exception, you need
configure the debugger for 2 things:
1. Correctly load symbols for all modules/assemblies in your application.
This is because the exception may be thrown by some .Net BCL code(not your
written code), you need the symbol for various BCL assemblies.
2. Debuggers are passed 2 notifications during one exception: first chance
and second chance. The first chance notification is passed to your debugger
immediately when the code generates the exception, so this is what you
want. If your debuggers ignore the first chance exception, the OS/CLR will
only display a text to the "Output" window and call the "Catch ex As
Exception" you provided. If no "Catch ex As Exception" for this exception
is found, the debugger will finally be passed second chance exception
notification.

For #1, to set the symbol server path in VS2005, you should input
"srv*c:\LocalSymbols*http://msdl.microsoft.com/download/symbols;" in the
Tools | Options | Debugging | Symbols as the directory. This will tell the
VS2005 debugger to lookup symbol from the Microsoft symbol server
"http://msdl.microsoft.com/download/symbols" and cache the downloaded
symbol in "c:\LocalSymbols" folder.

Additionally, there is a new feature named "Just My Code" which is enabled
by default in VS2005. This means that VS2005 will not load symbol for
non-user code assemblies, such as all .Net BCL assemblies. So you should
disable this "Just My Code" feature from Tools | Options | Debugging, and
uncheck "Enable Just My Code" check box.(the VS2005 IDE maybe need
close&re-open to enable the setting)

Below link contains more information regarding JMC feature:
"Is 'Just my Code' for you?"
http://blogs.msdn.com/greggm/archive...29/201315.aspx

To verify if the above 2 settings take effect, you may open "Module" window
after launching the application under debugger.

Note: symbol loading may require some time after you pressed F5, you may
check the "Output" window to verify the symbol loading process for each
modules.

For #2, you may open "Debug"->"Exceptions..." dialog, expand and find
"Common Language Runtime Exceptions" ->"System"->"System.ArgumentException"
node in the dialog. you should check the "Thrown" checkbox in the right and
click Ok. This tells the debugger to report the first chance exception to
the end user. Then you may open the "Call Stack" window to see the deepest
function frame for this exception.

Note: since you do not have the source code of .Net assemblies, debugger
may require you to open the "Disassembly" window for the exception code
location.

If you still have problem of locating the code accurately, I recommend you
create a little reproduce sample, I will give it a troubleshoot.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 8 '07 #3
Hi BBM,

Thanks for your feedback.

Yes, the "Output" window will always report the first chance exception
notification text. Once the execution control returns to the Catch block,
it means the debugger did not break on the first chance exception. In other
words, the debugger ignores the first chance exception.

Can you confirm if you enabled the first chance System.ArgumentException
break in VS2005 debugger? You may tell the debugger to break for first
chance ArgumentException by openning "Debug"->"Exceptions..." dialog,
expand and find "Common Language Runtime Exceptions"
->"System"->"System.ArgumentException" node in the dialog. You should check
the "Thrown" checkbox in the right and
click Ok. This tells the VS2005 to break for the first chance
ArgumentException.

I will wait for your further feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 9 '07 #4
BBM wrote:
<snip>
I solved the problem myself yesterday.
<snip>

Just out of curiosity, what was the solution? (if you don't mind
telling)

Regards,

Branco.

Jan 9 '07 #5
Hi BBM,

Based on my understanding, your .Net Winforma application is throwing
ArgumentException while executing a method, however, based on the code
review you can not understand why ArgumentException occurs, so you want to
find a way to identify the root cause of the ArgumentException.

First, can you tell me what version of debugger you are using, VS.net2003
or VS2005? I assume VS2005 now.

To accurately locate the code block generates the exception, you need
configure the debugger for 2 things:
1. Correctly load symbols for all modules/assemblies in your application.
This is because the exception may be thrown by some .Net BCL code(not your
written code), you need the symbol for various BCL assemblies.
2. Debuggers are passed 2 notifications during one exception: first chance
and second chance. The first chance notification is passed to your debugger
immediately when the code generates the exception, so this is what you
want. If your debuggers ignore the first chance exception, the OS/CLR will
only display a text to the "Output" window and call the "Catch ex As
Exception" you provided. If no "Catch ex As Exception" for this exception
is found, the debugger will finally be passed second chance exception
notification.

For #1, to set the symbol server path in VS2005, you should input
"srv*c:\LocalSymbols*http://msdl.microsoft.com/download/symbols;" in the
Tools | Options | Debugging | Symbols as the directory. This will tell the
VS2005 debugger to lookup symbol from the Microsoft symbol server
"http://msdl.microsoft.com/download/symbols" and cache the downloaded
symbol in "c:\LocalSymbols" folder.

Additionally, there is a new feature named "Just My Code" which is enabled
by default in VS2005. This means that VS2005 will not load symbol for
non-user code assemblies, such as all .Net BCL assemblies. So you should
disable this "Just My Code" feature from Tools | Options | Debugging, and
uncheck "Enable Just My Code" check box.(the VS2005 IDE maybe need
close&re-open to enable the setting)

Below link contains more information regarding JMC feature:
"Is 'Just my Code' for you?"
http://blogs.msdn.com/greggm/archive...29/201315.aspx

To verify if the above 2 settings take effect, you may open "Module" window
after launching the application under debugger.

Note: symbol loading may require some time after you pressed F5, you may
check the "Output" window to verify the symbol loading process for each
modules.

For #2, you may open "Debug"->"Exceptions..." dialog, expand and find
"Common Language Runtime Exceptions" ->"System"->"System.ArgumentException"
node in the dialog. you should check the "Thrown" checkbox in the right and
click Ok. This tells the debugger to report the first chance exception to
the end user. Then you may open the "Call Stack" window to see the deepest
function frame for this exception.

Note: since you do not have the source code of .Net assemblies, debugger
may require you to open the "Disassembly" window for the exception code
location.

If you still have problem of locating the code accurately, I recommend you
create a little reproduce sample, I will give it a troubleshoot.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 11 '07 #6
Hi BBM,

Sorry for the late response. I am sick leave at home these 2 days.

Thank you for sharing the result.

I am not sure what code your security.dll contains. It is strange that
without "InternalsVisibleTo" attribute will cause a strange
ArgumentException.

Since this root cause is not database related, is it possible for you to
create a little reproduce without the database dependency. Then I will try
to help you find the root cause.

This type of problem is really hard to find the root cause without the
local reproduce. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Victor Crudu | last post by:
Hi, could somebody help me to solve the follwing problem ? I get the following exception when i set as the DataSource of a DataGrid a DataTable. This situation can be only if I change...
4
by: | last post by:
Some time ago I installed VC# 2003, made a small generic project, compile with the allow unsafe flag and I get the error below: "error CS1577: Assembly generation failed -- Unexpected exception...
0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
2
by: Nony Buz | last post by:
My objective is simply: Notify a form when a image file has been created in a directory. First there is a basic interface for the callback function: public interface INewImageNotify { void...
2
by: Simon Harris | last post by:
I have created a web service, which when I call in my browser presents the text form etc. When I click the button, I get this error: System.ArgumentException: Cannot convert to System.Int32....
18
by: Atara | last post by:
In my apllication I use the following code: '-- My Code: Public Shared Function strDate2Date(ByVal strDate As String) As System.DateTime Dim isOk As Boolean = False If (strDate Is Nothing)...
3
by: Juhan | last post by:
Hi! I have a strange error in a console application that is hosted by IIS 5.0 and invokes a web service hosted on the same machine. A request form the web comes in and it is dispatched to a...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
2
by: ranjith konnoju | last post by:
hi, i am getting an exception while populating the data in the datagrid. am getting the values into datatable and binding it to the datagrid but it is not displaying the data and giving...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.