在成员资格提供者方法中显示异常 [英] showing exception in membership provider method

查看:60
本文介绍了在成员资格提供者方法中显示异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我找到问题的解决方法

MembershipUserCollection用户=新的MembershipUserCollection();


users = Membership.GetAllUsers();
它显示了这样的异常...

异常详细信息:System.InvalidCastException:指定的强制转换无效.


几个小时前一切正常,我能够从数据库中获取所有用户.....
我不知道发生了什么....
请帮助我解决这个问题....非常关键...

please help me in finding the solution of the problem

MembershipUserCollection users = new MembershipUserCollection();


users = Membership.GetAllUsers();
it shows the exception like this...

Exception Details: System.InvalidCastException: Specified cast is not valid.


it was working fine few hours ago and i was able to get all users from the database.....
i dont know what happened....
plz help me in this...very critical...

推荐答案

一旦可以正常工作,现在通常无法正常工作,则表示未引用正确的类型.

对System.Web.Security的引用可能已删除,或者项目可能已损坏.请检查您是否还有参考.

如果您在项目中定义一个名称相同的类(例如"Membership"或"MembershipUserCollection"),也会发生这种情况.

您可以尝试使用完全限定的名称,并检查类似...

System.Web.Security.MembershipUserCollection users = new System.Web.Security.MembershipUserCollection();

users = System.Web.Security.Membership.GetAllUsers();
Once worked and now not working generally means, it is not referring the correct type.

The reference to System.Web.Security may be removed or the project may be corrupted. Check you have the reference still.

It can also happen if you define a class in your project with same name like "Membership" or "MembershipUserCollection".

You can try using the fully qualified name and check like...

System.Web.Security.MembershipUserCollection users = new System.Web.Security.MembershipUserCollection();

users = System.Web.Security.Membership.GetAllUsers();


这篇关于在成员资格提供者方法中显示异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆