错误发生()
问题描述:
当我使用Membership.GetUser()
方法和包括using System.Web.Security;
命名空间中的错误显示,错误发生()
“类型‘System.Web.Security.MembershipUser’在 组件被定义没有引用您必须添加对程序集的引用 'System.Web.ApplicationServices,Version = 4.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'。C:\ Raj \ Orchard \ src \ Orchard.Web \ Modules \ test \ Controllers \ VideoController.cs“
答
您需要在Visual Studio项目的System.Web.ApplicationServices程序集上执行“添加引用”。请参考以下链接了解更多信息:How to: Add or Remove References in Visual Studio
在Visual C#
在Solution Explorer中添加一个引用,用鼠标右键单击该项目节点,然后单击添加 参考。
在“添加引用”对话框中,选择指示要引用的组件的类型的选项卡。
选择要引用的组件,然后单击确定。
答
Memebership
虽然类驻留在System.Web程序集,所述GetUser
方法返回MembershipUser
类型的对象和此类型在System.Web.ApplicationServices
组件定义。
因此,您需要添加对该程序集的引用,以便您可以在代码中使用上述类型。