-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Newbie Question/Problem
PostPosted: Thu Jan 05, 2006 3:27 pm 
Newbie

Joined: Thu Jan 05, 2006 1:49 pm
Posts: 2
Does any one know of any real simple examples of NHibernate in VB? I've been looking around and I only see them in C#. I can rewrite the code in VB that's not a big deal (ex Java Developer) but I keep running into problems and it would be nice to see an example in VB.

I'm mainly having problems adding the Assembly to the Config. I'm trying to use this example and keep getting stuck. Any help would be appreciated.

I'm using Hibernate 1.0.1 with SQL Server, .net framework 1.1.4. and VS .net 2003

I'm currently getting the following error:

File or assembly name NHibernate.Examples, or one of its dependencies, was not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: File or assembly name NHibernate.Examples, or one of its dependencies, was not found.


I've changed the "Build Action" on the Users.hbm.xml file to "Embedded Resource" and rebuilt several times.


TIA,
Terry


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 3:39 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Could your assembly have a different name? Can you post your mappings and config? It's hard to tell whether it is an error in the mappings, the config, or the assembly name.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 4:12 pm 
Newbie

Joined: Thu Jan 05, 2006 1:49 pm
Posts: 2
k-dub here they are. Thanks for looking at this.

===============================
Config setting from my web.config
===============================
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>

<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="hibernate.connection.connection_string" value="Server=WS1402;Database=NHibernate;User Id=user;Password=password;" />
</nhibernate>

</configuration>

===============================
User.hbm.xml
===============================
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" table="users">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="UserName" column="Name" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<property name="EmailAddress" type="String" length="40"/>
<property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>

===============================
User Class
===============================
Imports System

Namespace NHibernate.Examples.QuickStart
Public Class User
Private strId As String
Private strUserName As String
Private strPassword As String
Private strEmailAddress As String
Private datLastLogon As Date

Public Property Id() As String
Get
Return strId
End Get
Set(ByVal Value As String)
strId = Value
End Set
End Property

Public Property UserName() As String
Get
Return strUserName
End Get
Set(ByVal Value As String)
strUserName = Value
End Set
End Property

Public Property Password() As String
Get
Return strPassword
End Get
Set(ByVal Value As String)
strPassword = Value
End Set
End Property

Public Property EmailAddress() As String
Get
Return strEmailAddress
End Get
Set(ByVal Value As String)
strEmailAddress = Value
End Set
End Property

Public Property LastLogOn() As Date
Get
Return datLastLogon
End Get
Set(ByVal Value As Date)
datLastLogon = Value
End Set
End Property

Public Sub User()

End Sub


End Class
End Namespace

===============================
Snip from aspx page
===============================

Dim cfg As New Configuration
cfg.AddAssembly("NHibernate.Examples")
Dim factory As ISessionFactory = cfg.BuildSessionFactory()
Dim session As ISession = factory.OpenSession()
Dim transaction As ITransaction = session.BeginTransaction()

The classes, xml, config and aspx are in a single project in VS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.