Specific Question for the Microsoft Team

Element6

Well-known member
Joined
Feb 16, 2010
Messages
85
Programming Experience
5-10
This question is for the developers of .NET.

I have been throughly testing the framework on many levels, and I found an error I need clarified; if it's me or the framework.

I have an Indexed Property which is used to send credentials to determine if a property can be accessed get/set I end up with a strange error which tells me that the index cannot be qualified (Null Reference) and if I debug and step into where the code breaks and quick highlight the code; it says the null reference exception; however if I QucikView or Add To Watch, it says it also, but if I step into each layer of the credentials it qualifies and allows for it.

I have to think this is a runtime issue.

The Example I use is

VB.NET:
Class SomeObject2
Property LastVar as Object
End Class

Class SomeObject1
Property SomeVar as new SomeObject2
End Class

Property SomeVarA as SomeObject1

Property LookUpVar(IndexedProperty as SomeVarA) as Object

In this case I am sending user data (Name/Password etc..)

So the code looks like this

VB.NET:
LookUpVar(SecurityPass)

Initially it will say that the result is "Null Referenced"; but if I step into each layer seperately

VB.NET:
IndexedProperty
IndexedProperty.SomeVar
IndexedProperty.SomeVar.LastVar

It will qualify, any ideas? This is very pseudo code; don't take it literal just to give you an idea of what I am doing.
 
Your example is abit vague but it looks like the NullReferenceException would occur when trying to access a member of IndexedProperty.SomeVar.LastVar. It's really hard to say from the information provided. I'd be interested to see the actual exception data, i.e. the error message and stack trace of the exception and any inner exceptions.

Note: I answer this because the likelihood of it being seen and replied to by one of the people who developed Visual Studio is rather slim.
 
Let me give you some details; maybe that will help.

I have a Security class; which contains User Information and by instance functionality (I may consider making this shared but for now it's by instance).

The Security Class calls a function which checks against the security instance sent for permission levels. If the instance is nothing the security is considered invalid; and the design is on every access of every property and function. Nothing is exempt.

Associated, I use a Messanger class which logs each access and execute of functions; in this case as I said. I send the information and it is on the GET/SET accessor of the class property permissions level.

The code is already prehandled; if any of the values are null; I refuse the transaction before the actual GET or SET. In this case the security class is using itself to validate against; origionally I thought it was a recursion error; but after I reviewed the error I decided it wasn't because the recursion is terminated and when I stepped into the actual values from the first instance of the Security Class into the User Class and then the User Properties it allowed for it. However in runtime it says it is a null reference.

And it's intermidenant, only occurs occassionally; normally it works fine.
 
Last edited:
Opps, it's during the SET not the GET.

The Call Stack before the call that errors is :

VB.NET:
>	SUSAN.dll!SUSAN.BuildingBlocks.AIActivationFunction.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 161	Basic
 	SUSAN.dll!SUSAN.Framework.Functions.Globals.New() Line 418 + 0x22 bytes	Basic
 	[External Code]	
 	SUSAN.dll!SUSAN.GenericObject.New() Line 677 + 0xb bytes	Basic
 	SUSAN.dll!SUSAN.AIBuilder.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 176 + 0x9 bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.InitTestData() Line 12 + 0x2d bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.Intialize(SUSAN.UserInterface.UserControls.AIOutputBuffer AiOutputBuffer = {SUSAN.UserInterface.UserControls.AIOutputBuffer}) Line 265 + 0xa bytes	Basic
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormMain.FormMain_Load(Object sender = {SUSAN_SDK_IDE.FormMain}, System.EventArgs e = {System.EventArgs}) Line 21 + 0x27 bytes	Basic
 	[External Code]	
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormSplash.Timer1_Tick(Object sender = {Interval = 500}, System.EventArgs e = {System.EventArgs}) Line 41 + 0x12 bytes	Basic
 	[External Code]

After the main call during the SET is :

VB.NET:
>	SUSAN.dll!SUSAN.GenericObject.set_SecurityHandler(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}, SUSAN.Authentication.ISecurity value = {SUSAN.Authentication.Security}) Line 400	Basic
 	SUSAN.dll!SUSAN.BuildingBlocks.AIActivationFunction.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 161 + 0x20 bytes	Basic
 	SUSAN.dll!SUSAN.Framework.Functions.Globals.New() Line 418 + 0x22 bytes	Basic
 	[External Code]	
 	SUSAN.dll!SUSAN.GenericObject.New() Line 677 + 0xb bytes	Basic
 	SUSAN.dll!SUSAN.AIBuilder.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 176 + 0x9 bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.InitTestData() Line 12 + 0x2d bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.Intialize(SUSAN.UserInterface.UserControls.AIOutputBuffer AiOutputBuffer = {SUSAN.UserInterface.UserControls.AIOutputBuffer}) Line 265 + 0xa bytes	Basic
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormMain.FormMain_Load(Object sender = {SUSAN_SDK_IDE.FormMain}, System.EventArgs e = {System.EventArgs}) Line 21 + 0x27 bytes	Basic
 	[External Code]	
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormSplash.Timer1_Tick(Object sender = {Interval = 500}, System.EventArgs e = {System.EventArgs}) Line 41 + 0x12 bytes	Basic
 	[External Code]

At the line of error is :

VB.NET:
>	SUSAN.dll!SUSAN.GenericObject.set_SecurityHandler(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}, SUSAN.Authentication.ISecurity value = {SUSAN.Authentication.Security}) Line 408	Basic
 	SUSAN.dll!SUSAN.BuildingBlocks.AIActivationFunction.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 161 + 0x20 bytes	Basic
 	SUSAN.dll!SUSAN.Framework.Functions.Globals.New() Line 418 + 0x22 bytes	Basic
 	[External Code]	
 	SUSAN.dll!SUSAN.GenericObject.New() Line 677 + 0xb bytes	Basic
 	SUSAN.dll!SUSAN.AIBuilder.New(SUSAN.Authentication.ISecurity securityCredentials = {SUSAN.Authentication.Security}) Line 176 + 0x9 bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.InitTestData() Line 12 + 0x2d bytes	Basic
 	SUSAN.dll!SUSAN.RuntimeTest.Intialize(SUSAN.UserInterface.UserControls.AIOutputBuffer AiOutputBuffer = {SUSAN.UserInterface.UserControls.AIOutputBuffer}) Line 265 + 0xa bytes	Basic
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormMain.FormMain_Load(Object sender = {SUSAN_SDK_IDE.FormMain}, System.EventArgs e = {System.EventArgs}) Line 21 + 0x27 bytes	Basic
 	[External Code]	
 	SUSAN_SDK_IDE.exe!SUSAN_SDK_IDE.FormSplash.Timer1_Tick(Object sender = {Interval = 500}, System.EventArgs e = {System.EventArgs}) Line 41 + 0x12 bytes	Basic
 	[External Code]
 
s_SecurityHandler on quickwatch is : "Index is outside the bounds of the array." with an inner exception of Nothing.

If I step into it from s_SecurityHandler to User to Name or Password properties it qualifies fine.

Locals are :
- securityCredentials {SUSAN.Authentication.Security} SUSAN.Authentication.ISecurity
+ SUSAN.Authentication.Security {SUSAN.Authentication.Security} SUSAN.Authentication.Security
Credentials In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. SUSAN.Authentication.Security
DecryptKey {"Index was outside the bounds of the array."} String
EncryptKey Nothing String
LockPassword In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. String
Permissions 0 Integer
ProfileName Nothing String
SecurityMessage Nothing SUSAN.Messaging.StatusMessage
Type UserDefined {0} SUSAN.Authentication.Security.CryptologyTypeOf
User Nothing SUSAN.Authentication.UserCredentials

so the problem is at the DecryptKey level, I do not use arrays for that? So what is it referring to in this one instance.
 
Last edited:
Sorry the exception says :

A first chance exception of type 'System.IndexOutOfRangeException' occurred in SUSAN.dll
A first chance exception of type 'System.TypeInitializationException' occurred in SUSAN.dll


The Code for the property to give you some understanding of what I am doin g is.


VB.NET:
 ''' <summary>
        ''' The specific objects current decryption key; Assumes local security if used without AISecurity parameter.
        ''' </summary>
        ''' <returns>A String or Nothing</returns>
        <ComponentModel.CategoryAttribute("Security"), _
        ComponentModel.Browsable(True), _
        ComponentModel.ReadOnly(False), _
        ComponentModel.BindableAttribute(False), _
        ComponentModel.DefaultValueAttribute(""), _
        ComponentModel.DesignOnly(False), _
        ComponentModel.DescriptionAttribute("The specific objects current decryption key; Assumes local security if used without AISecurity parameter.")> _
        Public Overloads Property DecryptKey() As String Implements ISecurity.DecryptKey
            Get
                Return DecryptKey(s_SecurityHandler)
            End Get
            Set(ByVal value As String)
                DecryptKey(s_SecurityHandler) = value
            End Set
        End Property
        ''' <summary>
        ''' The specific objects current decryption key.
        ''' </summary>
        ''' <param name="SecurityCredentials" >The 'AISecurity' credentials of the caller.</param>
        ''' <returns>A String or Nothing</returns>
        Public Overloads Property DecryptKey(ByVal SecurityCredentials As ISecurity) As String Implements ISecurity.DecryptKey
            Get
                Dim returnValue As String = Nothing

                Dim AttemptedActionMessage As StatusMessage
                AttemptedActionMessage = LogAttemptedAction("Security.DecryptKey", Me, SecurityCredentials, Security.SecurityPermissionTypeOf.IsReadable)

                If AttemptedActionMessage.ResultAction >= StatusMessage.ResultActionTypeOf.Allowed Then
                    returnValue = s_DecryptKey
                End If

                Return returnValue
            End Get
            Set(ByVal value As String)
                Dim AttemptedActionMessage As StatusMessage
                AttemptedActionMessage = LogAttemptedAction("Security.DecryptKey", Me, securityCredentials, Security.SecurityPermissionTypeOf.IsWriteable)

                If AttemptedActionMessage.ResultAction >= StatusMessage.ResultActionTypeOf.Allowed Then
                    s_DecryptKey = value
                End If
            End Set
        End Property

The line of error occurs at the SecurityHandler Property lookup :

The code is.

VB.NET:
.
.
.
 s_Message.Caller = "User [ " + s_SecurityHandler.User(s_SecurityHandler).Name(s_SecurityHandler.User(s_SecurityHandler).LockPassword(SystemInternalPassword)) + " ]"
.
.
.
 
Last edited:
Discovered part of the problem;

I think the .NET framework is getting messed up some how.

I have a private variable A as boolean

If I step through the code; my security handler is fine.

When I set A to true it resets the permissions to 0 (I use the Unix 0-7 style permissions)

When I redeclare a new variable to replace A with say A0 it doesn't reset the permissions; so the only thing I can think of is that I lost a pointer to the correct data structures some how. Instead of pointing to A it's cycling through something else.

Is there a known "HACK" in .NET that allows for this?
 
Ok, this is a weird problem I figured out with a lot of trial and error.

Apparently; .NET stores the exceptions as an array or collection; in this case; I have a genericobject class (basic values like name, type, filename etc...) which is inherited throughout other classes (pretty routine) and I use the security handler to control property access according to user permissions.

This error resulted as a form of some how .NET was using or had used my RemoveFromArray function; and declared an "Index is out of Bounds" because I was removing an index from an array greater then the length in a different scope of the project not directly related to the error displayed.

It never reported it, and some how when the next error poped; it declared that was the error?

The fix was for me to handle the Function RemoveFromArray function; which had no direct relevance to the display data after I fixed that it worked fine.

I am assuming .NET stores the errors and reports them in a batch; but in this case it really twisted me up because I had no real way of determining if the code was incorrect it gave a false negative and pointed in the wrong area.
 
Also I am having a problem with Graphics GDI not getting the correct X,Y positions when I try to graphically set string data; it works in almost all cases but every now and then it offsets the X,Y cordinates? I have to assume this is a calculation error in the framework.

You can view the screen shot to get an idea.
I don't mind releasing the screenshot; and yes I am working on an Artifical Intellgence Builder.
 

Attachments

  • UploadScreenShot.png
    UploadScreenShot.png
    135.7 KB · Views: 44
Back
Top