I've setup a simple solution with separate assembly (not client profile)
for the model. The model in question is (i've included only one class for
brevity - there are two other very simple objects):
[ActiveRecord("NmToKms")]
public class NmToKms : ActiveRecordBase<NmToKms>
{
[PrimaryKey(PrimaryKeyType.Assigned, "nm")]
public float Nms { get; set; }
[Property("km")]
public float Kms { get; set; }
public NmToKms(float nms, float kms)
{
this.Nms = nms;
this.Kms = kms;
}
}
The main WinForm app initializes like so:
public Form1()
{
InitializeComponent();
IConfigurationSource source =
System.Configuration.ConfigurationManager.GetSection("activerecord") as
IConfigurationSource;
Assembly asm = Assembly.Load("WFTModels");
ActiveRecordStarter.Initialize(asm, source);
log4net.Config.XmlConfigurator.Configure();
}
I have a simple button handler to dump/recreate the DB (which is MySQL5.6):
private void recreateDB_Click(object sender, EventArgs e)
{
ActiveRecordStarter.DropSchema();
ActiveRecordStarter.CreateSchema();
And this works. So I'm certain connection to the DB is OK. I'm getting the
three tables I expect to see generated.
However; when I try to create and save a new object, I get an exception.
The code in question is this:
NmToKms nm = new NmToKms(10.00f, 14.50f);
nm.Create();
And the exception is below.
Any ideas? I also tried saving a simple object that didn't make use of the
'Single' type, just Strings. The exception is virtually identical. I'm a
bit lost as to what could be going on here. Pointers? Tips?
Thanks in advance,
Neil
--
Exception upon Save:
NHibernate.MappingException was unhandled
Message=Bad identifier type: Single
Source=NHibernate
StackTrace:
at
NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String
unsavedValue, IGetter identifierGetter, IType identifierType,
ConstructorInfo constructor)
at
NHibernate.Tuple.PropertyFactory.BuildIdentifierProperty(PersistentClass
mappedEntity, IIdentifierGenerator generator)
at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass
persistentClass, ISessionFactoryImplementor sessionFactory)
at
NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass
persistentClass, ICacheConcurrencyStrategy cache,
ISessionFactoryImplementor factory)
at
NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass
persistentClass, ICacheConcurrencyStrategy cache,
ISessionFactoryImplementor factory, IMapping mapping)
at
NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass
model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory,
IMapping cfg)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg,
IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at
Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory(Type
type) in
c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:line
135
at
Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession(Type type)
in
c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:line
185
at Castle.ActiveRecord.ActiveRecordBase.InternalCreate(Object
instance, Boolean flush) in
c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line
123
at Castle.ActiveRecord.ActiveRecordBase.Create(Object instance) in
c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line
100
at Castle.ActiveRecord.ActiveRecordBase.Create() in
c:\TeamCity\buildAgent\work\e41ee5ead2eba140\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line
1607
at WinFormCastleAR.Form1.recreateDB_Click(Object sender, EventArgs
e) in C:\Users\neil\documents\visual studio
2010\Projects\WinFormCastleAR\WinFormCastleAR\Form1.cs:line 42
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WinFormCastleAR.Program.Main() in c:\Users\neil\Documents\Visual
Studio 2010\Projects\WinFormCastleAR\WinFormCastleAR\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.InvalidCastException
Message=Unable to cast object of type 'NHibernate.Type.SingleType'
to type 'NHibernate.Type.IIdentifierType'.
Source=NHibernate
StackTrace:
at
NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String
unsavedValue, IGetter identifierGetter, IType identifierType,
ConstructorInfo constructor)
InnerException:
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.