ASP.Net Core 2.2 InProcess托管的Bug:unable to open database file
最近把项目更新到了ASP.Net Core 2.2,发布之后发现在IIS下使用SQLite数据库不行了,报异常说不能打开数据库。"unable to open database file",奇了个怪了。照理说这个不是权限就是路径错了,权限直接加了Everyone也无济于事,后来换成绝对路径就可以了,那说明确实是路径错了。
但是写的相对路径肯定是没错的,使用 dotnet 命令来运行也是正常的, dotnet ZKEACMS.WebHost.dll。
ConnectionString
"ConnectionString": "Data Source=Database.sqlite"
后来想起了之前有看过的这篇令人激动的文章:
就是2.2可以使用In Process的托管模式,说性能有惊天地泣鬼神的提升,就想说会不会是这玩意的问题,毕竟当初升级时也是我主动改的这个:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
</Project>
于是我改了一下web.config,切换成使用旧的模式: modules="AspNetCoreModuleV2" -> modules="AspNetCoreModule",然后程序就正常运行了。
妥妥的写个issue给微软:https://github.com/aspnet/AspNetCore/issues/6117
我再使用In Process的托管模式做了一下debug,看到了令人惊奇的结果,这个当前目录竟然变成了IIS的目录,难怪相对路径错了。

解决方式
主动设置一下当前目录为程序根目录:
System.IO.Directory.SetCurrentDirectory(hostingEnvironment.ContentRootPath);
ASP.Net Core 2.2 InProcess托管的Bug:unable to open database file的更多相关文章
- ASP.NET Core 进程内(InProcess)托管
ASP.NET Core 进程内(InProcess)托管 在 ASP.NET Core 中的进程内(InProcess)托管模型 什么是 Kestrel 服务器 当一个 ASP.NET Core 应 ...
- [07]ASP.NET Core 进程外(out-of-process)托管
ASP.NET Core 进程外(out-of-process)托管 本文作者:梁桐铭- 微软最有价值专家(Microsoft MVP) 文章会随着版本进行更新,关注我获取最新版本 本文出自<从 ...
- ASP.NET Core 进程外(out-of-process)托管
ASP.NET Core 进程外(out-of-process)托管 在本节中,我们将讨论 ASP.NET Core 中的Out Of Process Hosting. ASP.NET Core 进程 ...
- ASP.Net Core 2.2使用SQLite数据库unable to open database file
原文:ASP.Net Core 2.2使用SQLite数据库unable to open database file 最近把项目更新到了ASP.Net Core 2.2,发布之后发现在IIS下使用SQ ...
- [06]ASP.NET Core中的进程内(InProcess)托管
ASP.NET Core 进程内(InProcess)托管 本文作者:梁桐铭- 微软最有价值专家(Microsoft MVP) 文章会随着版本进行更新,关注我获取最新版本 本文出自<从零开始学 ...
- ASP.NET Core 2.2 和之前版本区别: 可以在IIS上进行ASP.NET核心进程托管 (翻译)
原文链接: https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22 ...
- Asp.Net Core 入门(一)——Program.cs做了什么
ASP.NET Core 是微软推出的一种全新的跨平台开源 .NET 框架,用于在 Windows.Mac 或 Linux 上生成基于云的新式 Web 应用程序.国内目前关于Asp.Net Core的 ...
- asp.net core 系列 2 启动类 Startup.CS
学无止境,精益求精 十年河东,十年河西,莫欺少年穷 学历代表你的过去,能力代表你的现在,学习代表你的将来 在探讨Startup启动类之前,我们先来了解下Asp.NET CORE 配置应用程序的执行顺序 ...
- netcore进程内(InProcess)托管和进程外(out-of-Process)托管
当一个 ASP.NET Core 应用程序执行的时候,.NET 运行时会去查找 Main()方法,因为它是这个应用程序的起点. 然后,Main()方法调用静态类WebHost中的静态方法CreateD ...
随机推荐
- tcp连接需要注意的问题
当有子进程时,子进程终止时会返回SIGCHLD信号,默认忽略,此时会有僵尸进程. 处理方法: 捕获信号,并waitpid. 当慢系统调用被中断时(如信号中断),有些系统不会自动重启调用,此时系统调用可 ...
- 用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn't match any of the subject alternative names问题的解决
最近用server酱-PushBear做消息自动推送,用apache HttpClient做https的get请求,但是代码上到服务器端就报javax.net.ssl.SSLException: Ce ...
- [leetcode]340. Longest Substring with At Most K Distinct Characters至多包含K种字符的最长子串
Given a string, find the length of the longest substring T that contains at most k distinct characte ...
- SyntaxError: Non-ASCII character '\xe5' in file D:/pcode/xx.py on line 21, but no encoding declared
from selenium import webdriver from datetime import * import time starttime = datetime.now() print ( ...
- jQuery控制TR显示隐藏
参考链接:http://www.jb51.net/article/51221.htm 通过jQuery的hide和show方法即可.
- Judy Array - Example
“ In computer science and software engineering, a Judy array is a data structure that has high perfo ...
- php调用C#写的dll包
1.转到需要注册的dll路径下 2.输入regasm命令+文件名 3问题解决
- 在Jmeter中用JAVA获取Rolling Date
Rolling Date_Weekly import java.util.*; import java.text.SimpleDateFormat; import java.text.DateForm ...
- 泛型约束where条件的使用(可以通过类型参数动态反射创建实例)
定义抽象的人类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- 关于apicloud图片缓存
imageCache如果是同一个地址,得到的缓存文件名字是一样的.可能是对url md5了一下. apicloud目前有两种清除方式1 一种是api.clearCache 另一种方法当然是强大的 ...