ASP.NET 中使用WebServer进行调试时,自定义的Identity出现 SerializationException的解决方法
2012-10-29 17:03
633 查看
今天遇到一个奇怪的问题,虽然已经解决了,但是原因仍然不是很清楚。
在新建的一个ASP.NET MVC中使用了自定义的Identity,在使用VS自带的WebServer调试时,发生了类似如下错误:
同样的代码,在使用IIS或IIS Express进行调试或运行时,就不会出错。
最初尝试根据提示添加Attribute [Serializable]但是错误依旧。
后来将原来Identity的定义由
改为
即解决,但是最终发生原因还是没有探明,从异常上看来,似乎是WebServer内部的一个Bug。
References:
http://stackoverflow.com/questions/1277371/serializationexception-on-customidentity-when-user-is-denied-in-asp-net
在新建的一个ASP.NET MVC中使用了自定义的Identity,在使用VS自带的WebServer调试时,发生了类似如下错误:
Type is not resolved for member'XAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'XAssembly.MyIdentity,XAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SerializationException: Type is not resolved for member 'XAssembly.MyIdentity,XAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.] Microsoft.VisualStudio.WebHost.Connection.get_RemoteIP() +0 Microsoft.VisualStudio.WebHost.Request.GetRemoteAddress() +65 System.Web.HttpRequest.get_UserHostAddress() +18 System.Web.HttpRequest.get_IsLocal() +13 System.Web.Configuration.CustomErrorsSection.CustomErrorsEnabled(HttpRequest request) +86 System.Web.HttpContext.get_IsCustomErrorEnabled() +42 System.Web.Configuration.UrlAuthFailedErrorFormatter.GetErrorText(HttpContext context) +16 System.Web.Security.UrlAuthorizationModule.WriteErrorMessage(HttpContext context) +29 System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +8777783 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
同样的代码,在使用IIS或IIS Express进行调试或运行时,就不会出错。
最初尝试根据提示添加Attribute [Serializable]但是错误依旧。
后来将原来Identity的定义由
public class MyIdentity : IIdentity{ //... }
改为
public class MyIdentity : MarshalByRefObject ,IIdentity{ //... }
即解决,但是最终发生原因还是没有探明,从异常上看来,似乎是WebServer内部的一个Bug。
References:
http://stackoverflow.com/questions/1277371/serializationexception-on-customidentity-when-user-is-denied-in-asp-net
相关文章推荐
- 关于asp.net网站发布后,使用登录控件和注册控件时出现“数据库只读,无法进行数据更新”的解决方法
- 在asp.net中使用ajax时出现的"'Sys' 未定义"的解决方法
- ASP.NET 使用js插件出现上传较大文件失败的解决方法(ajaxfileupload.js第一弹)
- VS2013调试的时候出现 “检测到在集成的托管管道模式下不适用的 ASP.NET 设置的解决方法”
- asp.net程序编译调试时偶尔出现访问被拒绝的错误的解决方法
- IIS6 下使用ASP.NET 4.0时浏览网站出现404错误的解决方法
- asp.net程序编译调试时偶尔出现访问被拒绝的错误的解决方法
- 关于使用asp.net调试器出现的问题及相关解决方法
- 解决asp.net Sharepoint无法连接发布自定义字符串处理程序,不能进行输出缓存处理的方法
- asp.net程序编译调试时偶尔出现访问被拒绝的错误的解决方法
- ASP.NET中使用UpdatePanel时用Response输出出现错误的解决方法
- VS2013调试的时候出现 “检测到在集成的托管管道模式下不适用的 ASP.NET 设置的解决方法”
- ASP.NET使用GridView时,出现错误“必须声明标量变量‘@ID’”的解决方法
- 尝试调试 ASP.NET Web 应用程序时出现权限错误的解决方法
- Asp.net中建立MS office组件时出现“拒绝访问”和“消息筛选器显示应用程序正在使用中”错误的解决方法
- ASP.NET Core2.0 使用VSCode 版本1.13.1工具 开发控制台运行出现中文乱码问题及解决方法
- ASP.NET 使用ajaxupload.js插件出现上传较大文件失败的解决方法
- VS调试ASP.NET MVC程序出现"未连接到互联网"的解决方法
- Win7和IE8下asp.net无法进行断点调试的解决方法