我试图在我的.Net Core应用程序中设置连接字符串,但我一直收到错误:
System.NullReferenceException:'对象引用未设置为对象的实例.'
我尝试将以下内容添加到appsettings.json:
"ConnectionStrings": {
"Analysis": "Server=DESKTOP-MYSERVER;Database=MYDATABASE;User Id=sa; Password=Password123;Provider=System.Data.SqlClient;Trusted_Connection=True;MultipleActiveResultSets=true;Pooling=false;"
}
Run Code Online (Sandbox Code Playgroud)
我也试过像以前那样使用web.config .Net Core:
<connectionStrings>
<add name="Analysis" providerName="System.Data.SqlClient"
connectionString="Server=DESKTOP-MYSERVER;Database=MYDATABASE;User Id=sm;Password=Password123;"/>
Run Code Online (Sandbox Code Playgroud)
然后在c#我有:
public List<DapperTest> ReadAll()
{
var data = new List<DapperTest>();
using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["Analysis"].ConnectionString))
{
data = db.Query<DapperTest>("select * from testTable").ToList();
}
return data;
}
Run Code Online (Sandbox Code Playgroud)
两种方式都给我例外:
System.NullReferenceException:'对象引用未设置为对象的实例.'
我使用了以下资源:
https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro
但我错过了一些东西.我只设置了一次连接字符串,它不在.Net Core中,因此对其他人来说可能是显而易见的.
我正在为 C++ 设置 YouCompleteMe,但是当我打开 .cpp 文件时,出现错误 NoExtraConfDetected: No .ycm_extra_conf.py file detector
.vimrc 文件如下所示:
set nocompatible " be iMproved, required filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'rdnetto/YCM-Generator'
Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = '$USER/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
" All of your Plugins must be added before the following line
call vundle#end() " …Run Code Online (Sandbox Code Playgroud)