自定义配置文件 asp.net
我正在尝试根据这篇文章使用 VB.NET 在 ASP.NET 中使用自定义配置文件: 如何分配配置文件值?
我在文件夹 /class/Usuario 下创建了我的配置文件类.vb 使用 Locus 命名空间。该类继承了上面帖子中指定的 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
End Namespace
I'm trying to use a custom profile in ASP.NET using VB.NET according to this post:
How to assign Profile values?
I created my profile class under the folder /class/Usuario.vb using the Locus namespace. The class inherits ProfileBase as specified in the post above.
The problem is that when I try to make a reference to that class on my web.config it gives me this error message:
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?)
This is how I'm declaring my web.config:
<profile defaultProvider="CustomizedProfileProvider" inherits="Locus.Usuario">
<providers>
<clear />
<add name="CustomizedProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="BDSIT" />
</providers>
</profile>
The "inherits" part is what's failing
I tried googling but I couldn't get it working
Any clues on what am I doing wrong?
Thanks in advance!
EDIT: This is the code of the class:
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
End Namespace
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在命名空间之前添加了项目名称,这解决了问题,如下所示:
我现在正在测试配置文件,但目前 IIS 不会抛出错误并且编译成功。
谢谢,我希望这对某人有帮助
I added the project name before the Namespace and that fixed the issue, somethint like this:
I'm now testing the profile but for now the IIS is not throwing the error and the compilation succeeds.
Thanks, I hope this helps someone
您是否在 web.config 中添加了对自定义命名空间的引用?
Have you added a reference to your custom namespace in web.config?