tqwhite like Diego said you need to set up your configuration(i havent seen
u mention setting it up anywhere). This is such that nhibernate can be able
to locate your mapping files(set as embedded resources) something of the
sort...... Configuration cfg = new Configuration();
cfg.AddAssembly("assemblyName"). At least that IMO is the cause of all your
problems.On Fri, Mar 5, 2010 at 6:48 AM, tqwhite <[email protected]> wrote: > You obviously have it too good in Argentina. You're going to have to > settle for my gratitude. > > Your patient explanation put me on the right track. I couldn't get the > addAssembly version to work, but putting the mapping clause into the > config file worked great. I plowed through a couple of type issues and > Voila!, Security Exception. > > > [SecurityException: That assembly does not allow partially trusted > callers.] > NHibernate.ByteCode.LinFu.ProxyFactory..cctor() +0 > > > I immediately went to my various bin directories and changed all of > the downloaded files so they are not blocked. No dice. > > I surfed the web and read that this is a common problem for > nHibernate, that it requires full trust. I looked into my IIS7 setup > and it is set to "Full (internal)". I changed it to High but it made > no difference. > > I googled about and found a lot of discussion of this problem. I added > > <trust level="Medium" originUrl="" /> > > to the config. And this > > using System.Security; > [assembly: AllowPartiallyTrustedCallers] > > to the class that configures nHibernate. No improvement so I removed > them. > > I don't know how to make my copy of Windows 7 operate as "Full Trust", > or honestly, what that means. > > Any thoughts? > > thanks, > tqii > > > > > > > > On Mar 4, 5:20 pm, Diego Mijelshon <[email protected]> wrote: > > My kids might probably go to the public university, which is free in > > Argentina, but thanks anyway. > > > > At some point in your code, you are creating a > NHibernate.Cfg.Configuration > > instance, from which you use BuildSessionFactory() to get the > sessionFactory > > you're using there. > > You need to tell the configuration where to get the mappings from. > > Since you already have the hbm.file(s) embedded in your assembly, you can > > either: > > - use the <mapping assembly="Assembly name"/> in the hibernate.cfg.xml > file > > - call configuration.AddAssembly(assembly) with the appropriate assembly > > instance or name. > > > > Diego > > > > > > > > On Thu, Mar 4, 2010 at 20:11, tqwhite <[email protected]> wrote: > > > First, tell me where your kids are going to college so I can start > > > scholarships for them. I can't tell you how much I appreciate this > > > help. > > > > > Also, I should note, so you can interpret my dopiness properly, that > > > I'm new to C#, .NET, strongly typed languages and WIndows. I've been a > > > php guy for the last decade, however. > > > > > I don't know how I am building my configuration. I have a working .NET > > > MVC project. I referenced in nHibernate (and Lin Fu when I got an > > > error requesting it). I grabbed hibernate.cfg.xml from the download > > > and changed the database string. Is that the configuration you mean? > > > > > I checked my project's properties to make sure that I have the right > > > assembly name. Is this what you are talking about:<hibernate-mapping > > > xmlns="urn:nhibernate-mapping-2.2" assembly="ExpressBook" > > > namespace="ExpressBook">? > > > > > I suspect that I am missing the meaning of your questions. Please ask > > > me more. > > > > > thanks, > > > tqii > > > > > On Mar 4, 4:54 pm, Diego Mijelshon <[email protected]> wrote: > > > > How are you building your configuration? > > > > More specifically, how are you adding the assembly? > > > > > > Diego > > > > > > On Thu, Mar 4, 2010 at 19:06, tqwhite <[email protected]> wrote: > > > > > I've spent the last two days trying to get my first bit of > nHibernate > > > > > to work. I am in "No Persister" hell. > > > > > > > Following is everything I have relative to this problem (what I've > > > > > tried, environment, file names, xml, classes, error text). > > > > > > > Please, for the love of all that is holy, help me!! > > > > > > > tqii > > > > > > > What I've tried: > > > > > > > I've moved the file around everywhere that makes sense. It is > > > > > presently in the same directory as the class. > > > > > I took out the class definition. Nothing changes at all. > > > > > I inserted stupid assembly and namespace definitions. Nothing > changes > > > > > at all. > > > > > I recreated my starter project a few times. Doesn't matter. > > > > > All of the alternatives to "embedded resource" that seemed > relevant. > > > > > It is presently embedded. > > > > > I changed the code to refer to a new class with a different name > but > > > > > left the hbm unchanged. Same error, different name. > > > > > > > Environment: > > > > > > > Windows 7 > > > > > ASP.NET MVC > > > > > ASP.NET 3.5 sp1 > > > > > Visual Studio 2008 > > > > > > > File names: > > > > > > > In the same directory > > > > > studentBase.cs > > > > > studentBase.hbm.xml > > > > > > > Also, hibernate.cfg.xml is in the top directory of the project. I > used > > > > > the sample with no changes except the connection string. I think > this > > > > > is being found properly because I can induce errors by changing it. > > > > > > > StudentBase.hbm.xml: > > > > > > > <?xml version="1.0" encoding="utf-8" ?> > > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > > > > assembly="ExpressBook" namespace="ExpressBook"> > > > > > <class name="ExpressBook.Services.BaseDataObjects.StudentBase, > > > > > ExpressBook"> > > > > > <id name="id" column="id" type="int32" unsaved-value="0"> > > > > > <generator class="native"> > > > > > </generator> > > > > > </id> > > > > > <property name="first" column="first" type="text" > not-null="false"/ > > > > > > > <property name="last" column="last" type="text" > not-null="false"/> > > > > > </class> > > > > > > > </hibernate-mapping> > > > > > > > StudentBase.cs: > > > > > > > using System; > > > > > using System.Collections.Generic; > > > > > using System.Linq; > > > > > using System.Web; > > > > > > > namespace ExpressBook.Services.BaseDataObjects > > > > > { > > > > > public class StudentBase > > > > > { > > > > > public virtual int id { get; set; } > > > > > public virtual string first { get; set; } > > > > > public virtual string last { get; set; } > > > > > } > > > > > } > > > > > > > The Offending Code: > > > > > > > Line 20: NHibernate.ISession session = > > > > > sessionFactory.OpenSession(); > > > > > Line 21: > > > > > Line 22: return > > > > > session.Get<Services.BaseDataObjects.StudentBase>(id); > > > > > > > The Error Message: > > > > > > > Stack Trace: > > > > > > > [MappingException: No persister for: > > > > > ExpressBook.Services.BaseDataObjects.StudentBase] > > > > > NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String > > > > > entityName) +103 > > > > > > NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent > > > > > event, LoadType loadType) +112 > > > > > NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType > > > > > loadType) +159 > > > > > NHibernate.Impl.SessionImpl.Get(String entityName, Object id) > +186 > > > > > NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) +137 > > > > > NHibernate.Impl.SessionImpl.Get(Object id) +175 > > > > > ExpressBook.Models.Student.getStudentById(Int32 id) in C:\Users > > > > > \tqwhite\Documents\Visual Studio > 2008\Projects\ExpressBook\ExpressBook > > > > > \Models\Student.cs:22 > > > > > ExpressBook.Controllers.DistrictController.getStudentById(Int32 > id) > > > > > in C:\Users\tqwhite\Documents\Visual Studio > 2008\Projects\ExpressBook > > > > > \ExpressBook\Controllers\DistrictController.cs:22 > > > > > lambda_method(ExecutionScope , ControllerBase , Object[] ) +79 > > > > > System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase > > > > > controller, Object[] parameters) +17 > > > > > > System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext > > > > > controllerContext, IDictionary`2 parameters) +178 > > > > > > System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext > > > > > controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 > > > > > parameters) +24 > > > > > > > > System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() > > > > > +52 > > > > > > System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilt > > > er > > > > > filter, ActionExecutingContext preContext, Func`1 continuation) > +254 > > > > > > > > System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() > > > > > +19 > > > > > > System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(Contro > > > llerContext > > > > > controllerContext, IList`1 filters, ActionDescriptor > actionDescriptor, > > > > > IDictionary`2 parameters) +192 > > > > > > > > System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext > > > > > controllerContext, String actionName) +314 > > > > > System.Web.Mvc.Controller.ExecuteCore() +105 > > > > > System.Web.Mvc.ControllerBase.Execute(RequestContext > > > > > requestContext) +39 > > > > > > System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestCon > > > text > > > > > requestContext) +7 > > > > > System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34 > > > > > System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() > > > > > +21 > > > > > > System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResu > > > lt > > > > > _) +12 > > > > > > > System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59 > > > > > System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult > > > > > asyncResult) +44 > > > > > > System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IA > > > syncResult > > > > > result) +7 > > > > > > System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionSt > > > ep.Execute() > > > > > +8679150 > > > > > > > System.Web.HttpApplication.ExecuteStep(IExecutionStep step, > > > > > Boolean& completedSynchronously) +155 > > > > > > > Version Information: Microsoft .NET Framework > Version:2.0.50727.4927; > > > > > ASP.NET Version:2.0.50727.4927 > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "nhusers" group. > > > > > To post to this group, send email to [email protected]. > > > > > To unsubscribe from this group, send email to > > > > > [email protected]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]>> > > > <nhusers%[email protected]<nhusers%[email protected]> > <nhusers%252bunsubscr...@googlegroup s.com>> > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/nhusers?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "nhusers" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]>> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
