Search the Community
Showing results for tags 'nhibernate'.
Found 2 results
-
Pessoal, estou iniciando um projeto em aps.net core, e estou tentando implementar o identity mas sem o entityframework, pois meu projeto será todo em nhibernate. Eu fiz o dev mas estou com um problema que não consigo resolver. Sempre que eu rodo meu projeto eu recebo a seguinte mensagem. InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[iFaiz.Web.Models.ApplicationUser]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[iFaiz.Web.Models.ApplicationUser]'. Pesquisando na internet tem muita informação sobre esse erro, e sempre mandam adicionar um comando no Startup que é esse abaixo: services.AddIdentity<Models.ApplicationUser, NHibernate.AspNetCore.Identity.IdentityRole>().AddDefaultTokenProviders(); Mas mesmo inserindo ele, nada muda, o erro continua igual. No meu Controller eu estou injetando a mesma classe. public AccountController( UserManager<Models.ApplicationUser> userManager ,SignInManager<Models.ApplicationUser> signInManager ,IEmailSender emailSender ,RoleManager<IdentityRole> roleManager ,ILogger<AccountController> logger ) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _roleManager = roleManager; _logger = logger; } Meu Startup public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var myEntities = new[] { typeof(Models.ApplicationUser) }; var configuration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012.ConnectionString(Configuration.GetConnectionString("ConexaoIFaiz")).ShowSql()) .ExposeConfiguration(cfg => { cfg.AddDeserializedMapping(MappingHelper.GetIdentityMappings(myEntities), null); }); var factory = configuration.BuildSessionFactory(); var session = factory.OpenSession(); var userManager = new UserManager<Models.ApplicationUser>(new UserStore<Models.ApplicationUser>(session),null, null, null,null, null,null,null,null); services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => { options.LoginPath = new PathString("/Acesso/Login"); options.AccessDeniedPath = new PathString("/Acesso/AcessoNegado"); }); services.AddMvc(config => { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); config.Filters.Add(new AuthorizeFilter(policy)); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddIdentity<Models.ApplicationUser, NHibernate.AspNetCore.Identity.IdentityRole>().AddDefaultTokenProviders(); } Por favor poderia me ajustar a resolver esse erro? Obrigado.
-
- asp.net core
- nhibernate
-
(and 1 more)
Tagged with:
-
c# "O inicializador de tipo de 'CriarGerenciadorDeSessao' acionou uma exceção."
rtavix posted a topic in .NET
Estou recendo essa mensagem de erro ao tentar compilar minha aplicação. Alguém poderia me orientar uma forma de resolver esse problema? Mensagem de erro: HibernateException: The IDbCommand and IDbConnection implementation in the assembly Oracle.DataAccess could not be found. Ensure that the assembly Oracle.DataAccess is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly. Classe nhibernateHelper: using System; using System.Collections.Generic; using System.Linq; using System.Text; using NHibernate.Mapping.Attributes; using NHibernate.Cfg; using NHibernate; using System.IO; using NHibernate.Context; namespace SDPJDominio.DataAccess { public class NhibernateHelper { private readonly ISessionFactory sessionFactory; public static ISession GetSessao() { return Instancia.GetSessionFactory().GetCurrentSession(); } private NhibernateHelper() { MemoryStream stream = new System.IO.MemoryStream(); HbmSerializer.Default.Validate = true; HbmSerializer.Default.Serialize(stream, System.Reflection.Assembly.GetExecutingAssembly()); stream.Position = 0; Configuration configuracao = new Configuration(); //configuracao = ConfigNhibernate.getConfig(configuracao); configuracao.Configure(); configuracao.SetProperty("connection.connection_string", ConfigNhibernate.getConfig()); //add essa linha configuracao.AddInputStream(stream); stream.Close(); sessionFactory = configuracao.BuildSessionFactory(); } public static ISessionFactory SessionFactory { get { return Instancia.sessionFactory; } } private ISessionFactory GetSessionFactory() { return sessionFactory; } public static NhibernateHelper Instancia { get { return CriarGerenciadorDeSessao.gerenciadorDeSessao; } } public static ISession AbrirSessao() { return Instancia.GetSessionFactory().OpenSession(); } public static void RecarregarSessao(object obj) { SessaoCorrente.Refresh(obj); } public static ISession SessaoCorrente { get { return Instancia.GetSessionFactory().GetCurrentSession(); } } class CriarGerenciadorDeSessao { internal static readonly NhibernateHelper gerenciadorDeSessao = new NhibernateHelper(); } } } Mensagem referente ao StackTrace: Name Value Type StackTrace " em SDPJDominio.DataAccess.NhibernateHelper.get_SessionFactory() na D:\\Repositório SVN\\SDP\\SDPJ\\branches\\SDPJ-v6.0.0\\SDPJDominio\\DataAccess\\NhibernateHelper.cs:linha 39" string