Fluentnhibernate.cfg.Fluentconfigurationexception.Getobjectdata how to resolve?

Asked

Viewed 143 times

0

I have a site that I use Fluentnhibernate and now I uploaded this site to the provider but when I try to open the site shows me some Exceptions of Fluentnhibernate. This site, on my computer, works very well without any problem, but the provider does not work. I looked for some ways to try to fix this, and found some people with the problem msm and who managed to solve Here , but I still can’t make it work.

How to solve this problem ?

Connection Class

public class DBConnect {
    private static ISessionFactory session;

    //hospedagem
    private const String HOST = "domain.com";    //ip servidor
    private const String USER = "user";         //usuario banco 
    private const String PASSWORD = "pass";         //senha banco
    private const String DB = "mydb";    //banco de dados

    //local
    //private const String HOST = "127.0.0.1";    //ip servidor
    //private const String USER = "root";         //usuario banco 
    //private const String PASSWORD = "";         //senha banco
    //private const String DB = "mydb";    //banco de dados



    //cria conexao com banco de dados
    private static ISessionFactory createConnection() {

        try{
            //verifica se a sessao esta vazia se nao estiver retorna a sessao
            if (session != null)
                return session;

            //configuracoes do banco de dados
            FluentConfiguration _config = Fluently.Configure().Database(MySQLConfiguration.Standard.ConnectionString(
                                                                        x => x.Server(HOST).
                                                                            Username(USER).
                                                                            Password(PASSWORD).
                                                                            Database(DB)
                                                                        ))
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<UsuarioMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<EstadoMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<CondadoMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TaxMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PropriedadeMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PropriedadeVisualizacaoMap>())
                                                                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<PropriedadeCurtidaMap>())
                                                                        .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true));

            session = _config.BuildSessionFactory();
            return session;
        }catch (FluentConfigurationException e){
            Debug.WriteLine("Erro DBConnect: " + e.InnerException.Message);
            return null;
        }
    }



    //abre a sessao para persistencia 
    public static ISession openSession() {
        try{
            return createConnection().OpenSession();
        }catch (FluentConfigurationException e){
            Debug.WriteLine("Erro OpenSession: " + e.InnerException.Message);
            return null;
        }        
    }

}

Fluentconfigurationexception

namespace FluentNHibernate.Cfg
{
    [Serializable]
    public class FluentConfigurationException : Exception
    {
        protected FluentConfigurationException(SerializationInfo info, StreamingContext context);
        public FluentConfigurationException(string message, Exception innerException);

        public override string Message { get; }
        public IList<string> PotentialReasons { get; }

        [SecurityCritical]
        public override void GetObjectData(SerializationInfo info, StreamingContext context);
        public override string ToString();
    }
}

Exception

Regras de segurança de herança foram violadas ao substituir membro: FluentNHibernate.Cfg.FluentConfigurationException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext). A acessibilidade de segurança do método de substituição deve corresponder à acessibilidade de segurança do método substituído.


[TypeLoadException: Regras de segurança de herança foram violadas ao substituir membro: 'FluentNHibernate.Cfg.FluentConfigurationException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. A acessibilidade de segurança do método de substituição deve corresponder à acessibilidade de segurança do método substituído.]
   DBConnect.openSession() +0
   InvestimentosUSA.Controllers.HomeController..ctor() +24

[TargetInvocationException: Uma exceção foi acionada pelo destino de uma chamada.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +114
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.Activator.CreateInstance(Type type) +11
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55

[InvalidOperationException: An error occurred when trying to create a controller of type 'InvestimentosUSA.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +178
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +76
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +66
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +194
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.