小编mem*_*m27的帖子

SQLite.Interop无法在清除解决方案时删除文件

System.Data.SQLite在MVC Web应用程序中使用Nuget包.当我尝试清理解决方案并重建时,似乎存在锁定问题.我得到的错误信息是: Unable to delete file "bin\x64\SQLite.Interop.dll". Access to the path '\bin\x64\SQLite.Interop.dll' is denied.

我认为数据库仍处于打开状态或.dll仍在使用中,但我找不到任何文档或对同一问题的任何引用.这个问题 似乎是一个类似的问题,但没有解决我的问题.

这是我用来写入SQLite数据库的代码片段:

        var conn = new SQLiteConnection("Data Source=" + connectionString);
        conn.Open();

        var debugEntriesTableQuery = "CREATE TABLE ...";

        var cmd = conn.CreateCommand();

        cmd.CommandText = debugEntriesTableQuery;

        cmd.ExecuteNonQuery();

        conn.Close();
Run Code Online (Sandbox Code Playgroud)

是否需要另一个步骤来正确关闭与数据库的连接并通知dll并且连接已关闭?

我在一个数据解决方案中使用此代码,我已将其添加到nuget包并在另一个解决方案中使用.在构建/清理使用我的nuget包的解决方案时,我只遇到此问题.

c# asp.net sqlite dll visual-studio

8
推荐指数
1
解决办法
1447
查看次数

Asp .Net Identity 2 - 密码更新后注销其他会话(使用安全戳)也会注销当前会话

当用户更改密码时,我需要立即使其无效并注销任何其他已登录的会话,但允许活动会话(刚刚更新其密码的用户)保持登录状态.

为此,我UpdateSecurityStampAsync(currentUser.Id);在UserManager上使用该方法.所有其他会话都已成功注销,但是SignInAsync在更新安全标记后调用后,活动会话也会被注销.

我正在使用的身份配置如下:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Login"),
    Provider = new CookieAuthenticationProvider
    { 
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
            validateInterval: TimeSpan.FromMinutes(0),
            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
    },
    CookieHttpOnly = true,
    CookieSecure = CookieSecureOption.SameAsRequest,
    SlidingExpiration = false,
    ExpireTimeSpan = TimeSpan.FromMinutes(10)
});
Run Code Online (Sandbox Code Playgroud)

正在更新密码,更新安全标记以及据称将当前用户重新登录的控制器代码段是:

var updateResult = await _userManager.ChangePasswordAsync(currentUser.Id, form.CurrentPassword, form.NewPassword);
if (!updateResult.Succeeded)
{
    //handle update failure
}

_signInManager.AuthenticationManager.SignOut();     

//updating the security stamp invalidates all other sessions
await _userManager.UpdateSecurityStampAsync(currentUser.Id);

await _signInManager.SignInAsync(currentUser, false, false);
Run Code Online (Sandbox Code Playgroud)

运行代码后,密码成功更新,并且由于更新了安全标记,所有会话都将被注销.但基于我见过的其他示例(如Chris的回答),上面的代码应刷新auth …

c# asp.net asp.net-mvc owin asp.net-identity

6
推荐指数
1
解决办法
820
查看次数

标签 统计

asp.net ×2

c# ×2

asp.net-identity ×1

asp.net-mvc ×1

dll ×1

owin ×1

sqlite ×1

visual-studio ×1