我在这里碰到了一个泡菜。我有一个自定义配置文件,我在两个应用程序中使用了相同的解决方案。第一个是构建的Web应用程序,用于将旧的.net应用程序中的一组自定义用户配置文件和属性导入到.net成员身份,角色,配置文件表中。我构建了一个从配置文件继承的配置文件公共类。这两个应用程序在其命名空间中都有相同类的副本。.net配置文件提供程序和自定义配置文件。设置属性“'未找到。
using System;
using System.Web.Security;
using System.Web.Profile;
using System.Collections.Specialized;
namespace WebProject
{
public class ProfileCommon : ProfileBase
{
public static ProfileCommon GetUserProfile(string username)
{
return Create(username) as ProfileCommon;
}
public static ProfileCommon GetUserProfile()
{
return Create(Membership.GetUser().UserName) as ProfileCommon;
}
[SettingsAllowAnonymous(false)]
public string FirstName
{
get
{
return base["FirstName"] as string;
}
set
{
base["FirstName"] = value;
}
}
[SettingsAllowAnonymous(false)]
public string LastName
{
get
{
return base["LastName"] as string;
}
set
{
base["LastName"] = value;
}
}
[SettingsAllowAnonymous(false)]
public string Email
{
get
{
return base["Email"] as string;
}
set
{
base["Email"] = value;
}
}
[SettingsAllowAnonymous(false)]
public StringCollection Sites
{
get
{
return base["Sites"] as StringCollection;
}
set
{
base["Sites"] = value;
}
}
}
}
我在我的web配置文件中的配置文件提供程序部分看起来像这样。
<profile defaultProvider="WebProjectProfileProvider" inherits="WebProject.ProfileCommon">
<providers>
<clear />
<add name="WebProjectProfileProvider" applicationName="/" type="System.Web.Profile.SqlProfileProvider" connectionStringName="Test"/>
</providers>
</profile>
如果我使用一个应用程序来执行用户导入,另一个使用的会员,角色和我创建的配置文件会变成这样导致“设置属性‘’没有被发现。”错误?我似乎无法查明错误发生的位置以及我已检查的一些最常见原因。这是我第一次在如此大规模的.net中使用这个功能。任何帮助是极大的赞赏。
谢谢。
你在哪里指定了可用的设置名称和类型?如果我没有记错,它们也应该在Web.config文件中指定。 – Venemo
指定的名称和类型在Profile Common类本身内。因为我在web.config中使用。它会自动知道使用上面列出的Profile Common类中的类型。如果我不使用“inherits”属性,则.net框架将在运行时抛出一个错误,指出该属性未被声明。如果不使用inherits属性,则开发人员必须使用节点在web.config文件中声明名称和类型。 –
gsirianni