views:

139

answers:

1

All my data logic is in another data layer project that I reference in my asp.net mvc project.

Now if I call:

CategoryDAO.GetById(1);

Everything works fine.

If I call:

CategoryDAO.GetBlah(1);

VS.NET complains saying

"Error 102: The type 'NHibernate.Criterion.Order' is defined in an assembly 
that is not referenced. You must add a reference to assembly 'NHibernate,
Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'."

If I add nhibernate.dll as a reference in my web project, it works.

Why is this? The logic/code is in my data layer, it is return the same as the call to GetById(1), why do I need to add the reference?

+1  A: 

I'm guessing it's because of the lazy-loading that comes build into your objects. NHibernate creates proxy objects that inherit from your class (which is why you need to declare your methods as virtual). I'm guessing the reference is needed because of the proxy objects.

Mike C.
The proxies are created by castle dynamic proxy or by linfu
Paco
Ah, thanks for the info. I'm still a newbie at NHibernate.
Mike C.