C#错误System.InvalidCastException [英] C# error System.InvalidCastException
本文介绍了C#错误System.InvalidCastException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
System.InvalidCastException在以下行:
System.InvalidCastException on following line:
If (System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated = False) Then
CType(System.Threading.Thread.CurrentPrincipal.Identity,
System.Web.ClientServices.ClientFormsIdentity).RevalidateUser()
推荐答案
我相信您会收到此错误:
无法将类型为"System.Security.Principal.GenericIdentity"的对象转换为类型为"System.Web.ClientServices.ClientFormsIdentity"的对象.
只要您未通过身份验证,就会发生这种情况.要获取FormsIdentity
,您需要已通过身份验证.
请参考: http://forums.asp.net/t/1114649.aspx/1 [ ^ ]
I believe you get this error:
Unable to cast object of type ''System.Security.Principal.GenericIdentity'' to type ''System.Web.ClientServices.ClientFormsIdentity''
This will occur as long as you are not authenticated. To get theFormsIdentity
you need to have been authenticated.
Refer: http://forums.asp.net/t/1114649.aspx/1[^]
上面的问题将是
无法将类型为"System.Security.Principal.GenericIdentity"的对象转换为类型为"System.Web.ClientServices.ClientFormsIdentity"."
以下线程也将非常有用,请检查此...
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22592880.html [ ^ ]
The above issue will be
"Unable to cast object of type ''System.Security.Principal.GenericIdentity'' to type ''System.Web.ClientServices.ClientFormsIdentity''."
The following thread will also be useful, Check this...
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22592880.html[^]
这篇关于C#错误System.InvalidCastException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文