2013-12-20 4 views
0

Ниже код работает нормально в локальной системе, но метания ошибки в сервере ...Fluent NHibernate исключение безопасности отображения

public class Employee 
{ 
    public virtual Int32 Emp_ID { get; set; } 
    public virtual String Name { get; set; } 
    public virtual String Email { get; set; } 
    public virtual String Mobile { get; set; } 
    public virtual String Address { get; set; } 
    public virtual String Username { get; set; } 
    public virtual String Password { get; set; } 
    public virtual String Designation { get; set; } 
    public virtual String Reference { get; set; } 
    public virtual Boolean IsWorking{get;set;} 
    public virtual IList<Timesheet> Timesheet { get; set; } 


    #region Object Overrides 

    /// <summary> 
    /// Method that checkes if the given User instance is equivalent to the current User Instance 
    /// </summary> 
    /// <param name="obj"></param> 
    /// <returns></returns> 
    public override bool Equals(object obj) 
    { 
     if (obj is Timesheet) 
     { 
      Timesheet compareTo = (Timesheet)obj; 
      return compareTo.Timesheet_ID.Equals(this.Timesheet); 
     } 
     else 
     { 
      return base.Equals(obj); 
     } 
    } 

    /// <summary> 
    /// ToString of Product Instance returns the Product Code 
    /// instead of the Itme Object's String representation 
    /// </summary> 
    /// <returns></returns> 
    public override string ToString() 
    { 
     return this.Name; 
    } 

    /// <summary> 
    /// Method that gets the Hash Code of the Object's Unique Identifier 
    /// </summary> 
    /// <returns></returns> 
    public override int GetHashCode() 
    { 
     return this.Emp_ID.GetHashCode(); 
    } 

    #endregion 
} 


public class Timesheet 
{ 
    public virtual Int32 Timesheet_ID { get; set; } 
    public virtual Employee Employee { get; set; } 
    public virtual Client Client { get; set; } 
    public virtual Project Project { get; set; } 
    public virtual Activity Activity { get; set; } 
    public virtual DateTime Date { get; set; } 
    public virtual String TimeSpent { get; set; } 
    public virtual String Comments { get; set; } 
    public virtual Boolean IsApproved { get; set; } 

    public Timesheet() 
    { 
     Employee = new Employee(); 
    } 
} 

связанных классов отображения является

public class EmployeeMap : ClassMap<Employee> 
{ 
    public EmployeeMap() 
    { 
     // Table name as in database 
     Table("tblEmployee"); 

     // Fields mapping to the Database 
     Id(x => x.Emp_ID).GeneratedBy.Increment(); 
     Map(x => x.Name); 
     Map(x => x.Email); 
     Map(x => x.Mobile); 
     Map(x => x.Address); 
     Map(x => x.Username); 
     Map(x => x.Password);   
     Map(x => x.Designation); 
     Map(x => x.Reference); 
     Map(x => x.IsWorking); 

     HasManyToMany(x => x.Timesheet).Table("tblEmpTimesheet").ParentKeyColumn("Emp_ID").ChildKeyColumn("Timesheet_ID");   
    } 

public class TimesheetMap 
{ 
    public TimesheetMap() 
    { 
     // Table name as in database 
     Table("tblEmpTimesheet"); 

     // Fields mapping to the Database 
     Id(x => x.Timesheet_ID).GeneratedBy.Increment(); 
     Map(x => x.Date); 
     Map(x => x.TimeSpent); 
     Map(x => x.Comments); 
     Map(x => x.IsApproved).Default("false"); 

     // Relationships with Other Objects 
     References<Employee>(x => x.Employee).Column("Emp_ID"); 
    } 
} 

метания ошибки исключения безопасности при попытке для доступа к emplyee от расписания или наоборот.

IQuery query = session.CreateQuery(String.Format("from {0} where {1} ='{2}'", "Timesheet", "Employee", 1)); 
IList<Timesheet> timeSheet= query.List<Timesheet>(); 
+0

какое исключение? Что говорит stacktrace? – MichaC

+0

: System.Security.SecurityException: эта сборка не позволяет частично доверять вызывающим абонентам. – user1934414

ответ

0

Кажется, ваш сервер ru ning вашего веб-приложения в среде с надежным доверием. Это требует, чтобы вы изменили несколько настроек в nhibernate, чтобы запустить nh.

Скорее всего замок прокси материал плохой парень ...

Попробуйте следовать инструкциям explained here.

+0

Спасибо за помощь .... Я делаю бесплатные настройки через global.ascx, но не из web.config, как вы упомянули, чтобы изменить настройки через web.config ... – user1934414

+0

u попытался защитить эту защищенную void Application_Start() { Инициализатор .RegisterBytecodeProvider (новый EntityInjector()); ... } – user1934414

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