2010-07-06 4 views
1

Я использую ленивую загрузку в своем приложении. Когда я работаю на мой исходный код и посмотреть его в браузере нет никаких проблем, но когда я опубликовать мое веб-приложение, показали, что это ошибка:Ошибка при ленивой загрузке с помощью NHibernate

The following types may not be used as proxies: 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsToChanged should be 'public/protected virtual' or 'protected internal virtual' 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsFromChanged should be 'public/protected virtual' or 'protected internal virtual' 
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: NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsToChanged should be 'public/protected virtual' or 'protected internal virtual' 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsFromChanged should be 'public/protected virtual' or 'protected internal virtual' 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[InvalidProxyTypeException: The following types may not be used as proxies: 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.Common.OrganizationalMonth: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.GroupTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.BusinessFramework.PartyService.BusinessEntities.RoleTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.JobTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Training.BusinessEntities.ClassSession: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.EmployeeWelfareTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.MissionOrderTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.StaffOrderComputaionTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpStartDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.Staff.BusinessEntities.InsuranceContractTimeFrame: field bkpEndDate should not be public nor internal 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsToChanged should be 'public/protected virtual' or 'protected internal virtual' 
Faraconesh.EnterpriseAppUnits.OfficeAutomation.BusinessEntities.SendingInformation: method IsFromChanged should be 'public/protected virtual' or 'protected internal virtual'] 
    NHibernate.Cfg.Configuration.ValidateEntities() +347 
    NHibernate.Cfg.Configuration.Validate() +13 
    NHibernate.Cfg.Configuration.BuildSessionFactory() +31 
    Faraconesh.ApplicationFramework.Core.DataAccess.NHibernateSessionManager.InitSessionFactory() +804 
    Faraconesh.ApplicationFramework.Core.DataAccess.NHibernateSessionManager..ctor() +39 
    Faraconesh.ApplicationFramework.Core.DataAccess.Nested..cctor() +39 

[TypeInitializationException: The type initializer for 'Nested' threw an exception.] 
    Faraconesh.ApplicationFramework.Core.DataAccess.NHibernateSessionManager.get_Instance() +61 
    System.Web.Administration.WebAdminModule.CommitAndCloseSession(Object sender, EventArgs e) +247 
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

чем причина. Как я могу решить эту проблему. Я использую NHibernate 2.1.2 и xml mapping.

ответ

2

Я думаю, что вы ищете параметр use_proxy_validator, установите для него значение false в вашей конфигурации.

Кроме того, вы можете посмотреть на this thread

1

Вы должны отметить bkpStartDate и другие как virtual

Смежные вопросы