Bogus System.ArgumentException has me puzzled

G

Guest

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
 
J

Jeffrey Tan[MSFT]

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/2004/07/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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

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/2004/07/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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

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]" said:
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/2004/07/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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Branco Medeiros

BBM wrote:
I solved the problem myself yesterday.
<snip>

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

Regards,

Branco.
 
J

Jeffrey Tan[MSFT]

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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top