自定义配置文件asp.net

时间:2010-11-04 00:15:52

标签: .net asp.net vb.net profiler

根据这篇文章,我正在尝试使用VB.NET在ASP.NET中使用自定义配置文件: How to assign Profile values?

我使用Locus命名空间在/class/Usuario.vb文件夹下创建了我的配置文件类。该类继承了上面帖子中指定的ProfileBase。

问题是,当我尝试在web.config上引用该类时,它会给出以下错误消息:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
Compiler Error Message: CS0246: The type or namespace name 'Locus' could not be found (are you missing a using directive or an assembly reference?)

这就是我宣布我的web.config:

的方式
  <profile defaultProvider="CustomizedProfileProvider" inherits="Locus.Usuario">
    <providers>
      <clear />
        <add name="CustomizedProfileProvider"
             type="System.Web.Profile.SqlProfileProvider"
             connectionStringName="BDSIT" />          
    </providers>
  </profile>   

“继承”部分是失败的

我尝试使用谷歌搜索,但我无法正常工作

关于我做错了什么的线索?

提前致谢!

编辑:这是该类的代码:

Namespace Locus
Public Class Usuario
    Inherits ProfileBase

    Public ReadOnly Property UsuarioActual() As Usuario
        Get
            Return ProfileBase.Create(Membership.GetUser.UserName)
        End Get
    End Property

    Public Property nombre() As String
        Get
            Return Me.GetPropertyValue("nombre")
        End Get
        Set(ByVal value As String)
            Me.SetPropertyValue("nombre", value)
            Save()
        End Set
    End Property

    Public Property apellido() As String
        Get
            Return Me.GetPropertyValue("apellido")
        End Get
        Set(ByVal value As String)
            Me.SetPropertyValue("apellido", value)
            Save()
        End Set
    End Property

    Public Property pin() As String
        Get
            Return Me.GetPropertyValue("pin")
        End Get
        Set(ByVal value As String)
            Me.SetPropertyValue("pin", value)
            Save()
        End Set
    End Property

End Class

结束命名空间

2 个答案:

答案 0 :(得分:1)

我在命名空间之前添加了项目名称并修复了问题,有些像这样:

<profile defaultProvider="CustomizedProfileProvider" inherits="ProjectName.Locus.Usuario">

我现在正在测试配置文件但是现在IIS没有抛出错误并且编译成功。

谢谢,我希望这有助于某人

答案 1 :(得分:0)

您是否在web.config中添加了对自定义命名空间的引用?

<namespaces>
<add namespace="Locus" />
</namespace>