Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Ocorreu uma excessão ao compilar o programa

Ao compilar o programa ocorreu uma exceção da qual não sei resolver por ser iniciante com o Visual Studio e C#. Mesmo fazendo os códigos e pastas tudo igual a vídeo aula...

Debugger:Stopped at Exception: Configure An exception was caught by the debugger, and user settings indicate that a break should occur.

Debugger:Exception Intercepted: RecuperaConfiguração, NHibernateHelper.cs line 17 An exception was intercepted and the call stack unwound to the point before the call from user code where the exception occurred. "Unwind the call stack on unhandled exceptions" is selected in the debugger options.

3 respostas

Olá, Fernando!

Você pode colocar aqui pra gente o código do arquivo NHibernateHelper.cs, para modermos investigar melhor o problema?

Obrigado!

Então, o erro "acontece" na linha do cfg.Configure();

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace Loja.Infra
{
    public class NHibernateHelper
    {
        public static Configuration RecuperaConfiguração()
        {
            Configuration cfg = new Configuration();
            cfg.Configure();
            cfg.AddAssembly(Assembly.GetExecutingAssembly());
            return cfg;
        }

        public static void GeraSchema()
        {
            Configuration cfg = RecuperaConfiguração();
            new SchemaExport(cfg).Create(true, true);
        }
    }
}
solução!

Descobri o problema... o meu arquivo hibernate.cfg.xml não estava sendo copiado para a pasta DEBUG, mesmo com a opção "Copy Aways ". Copiei manualmente ele para lá e funcionou...

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software