ClaimsIdentity NullReferenceException after installing .NET 4.5

I have an existing .Net 4 solution developed in vs2010 that uses the IIdentity implementation, which is used to determine the user of the current request. Now I want to use vs2012 to continue its development.

I opened the solution in vs2012 and set the target structure in properties as .Net 4. However, when I run the solution, I get an exception when the web server deserializes the GenericIdentity object. An exception occurs in

at System.Security.Claims.ClaimsIdentity.<get_Claims>d__0.MoveNext()
at System.Security.Principal.GenericIdentity.OnDeserializedMethod
                                                  (StreamingContext context)

The reason for the exception is that the Claims property is not initialized.

What I already know:

  • .Net 4.5 updates .Net 4 on the target machine, rather than running side by side.

  • GenericIdentity is now derived from the new ClaimsIdentity class in .Net 4.5

  • Setting the target structure for .Net 4 means that although the code still works with .NET 4.0, implementation 4.5 is used under covers, i.e. you do not see the hierarchy in the browser of visual studio objects, but the debugger and reflector show the output.

  • GenericIdentity.OnDeserializedMethod accesses the ClaimsIdentity Claims property without checking for null, throwing a NullReferenceException

One solution I came across that my own Identity object inherits from System.MarshalByRefObject, but the problem is that the custom Identity object is provided with a "Single Sign On" .dll, which is used in all systems of our organization. This means that I do not have access to him to change his heirachy heredity.

Is there an alternative solution or workaraound for this problem?

+4
1

Visual Studio, , , IIS , , .

appDomain, .

: .NET 4.5.1

0

All Articles