我想使用最新版本的ASP.NET Core,因为我想用它创建一组Web API.但是,我发现的教程主要关注实体框架.我无法使用它,因为我已经拥有"遗留"数据库,因此Code-First方法不是一种选择.
我的想法是使用ADO.NET连接到我的数据库,但我不知道是否System.Data.SqlClient在ASP.NET Core项目中可用.我已经发现,当我使用.NET Framework项目模板但是它仍然可以在.NET Core项目中使用时可用吗?
由于.NET Core中没有ConfigurationManager类,现在我必须在appsettings.json中设置config而不是web.config
根据这篇博文,我必须在那里设置我的配置,所以我喜欢这样:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Conexion": {
"name" : "empresas",
"connectionString": "Data Source=empresas;Initial Catalog=CATALMA; Integrated Security=True;",
"providerName": "System.Data.SqlClient"
}
}
Run Code Online (Sandbox Code Playgroud)
我只是写了"Conexion".
现在我在ViewModels文件夹中创建了以下类:
public class ConexionConfig
{
public string name { get; set; }
public string connectionString { get; set; }
public string providerName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在,在Startup.cs中,在ConfigureServices方法中,我必须通过以下方式添加它:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.Configure<ConexionConfig>(Configuration.GetSection("Conexion"));
services.AddMvc();
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,我收到以下错误:
Argument 2: cannot …Run Code Online (Sandbox Code Playgroud) 我有一个Xamarin.Forms解决方案,它在每个项目(Android,iOS和Windows 8.1)中包含一个名为Plugin.SecureStorage的库:https: //github.com/sameerkapps/SecureStorage 我在每个项目中通过NuGET安装它.
在iOS和Windows 8.1中一切正常,问题出在Android上.Android中的项目构建正确,但在启动时我得到这个:
[...]
Loaded assembly: MonoDroidConstructors [External]
09-27 18:14:49.880 D/Mono (30329): Assembly Ref addref AppConsume.Droid[0xb8cb0608] -> mscorlib[0xb8c64bc0]: 23
09-27 18:14:49.890 D/Mono (30329): Assembly Ref addref Xamarin.Forms.Core[0xb8cbca58] -> System.Collections[0xb8cc5980]: 3
09-27 18:14:49.900 D/Mono (30329): Assembly Ref addref Xamarin.Forms.Core[0xb8cbca58] -> System.Threading[0xb8cd4948]: 3
09-27 18:14:49.930 D/Mono (30329): Assembly Ref addref AppConsume.Droid[0xb8cb0608] -> Plugin.SecureStorage[0xb8cb43f8]: 2
Unhandled Exception:
System.TypeLoadException: Could not resolve type with token 01000019
Run Code Online (Sandbox Code Playgroud)
它的意思是什么?对我来说有点神秘.我该如何解决这个问题?
当然,作为一项要求,我添加了这一行......
SecureStorageImplementation.StoragePassword = "mypass";
Run Code Online (Sandbox Code Playgroud)
在Android项目的MainActivity.cs中......
using System;
using Android.App;
using Android.Content.PM;
using …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 Yii2 框架。在登录页面中,当我登录失败时,它只会刷新视图,但不会显示任何错误。这是我目前的看法:
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */
//$this->title = 'Welcome to my site';
//$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-login">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-4">
<div class="well no-padding">
<?php $form = ActiveForm::begin(["id"=>"login-form", "options"=>["class"=>"smart-form client-form"]]); ?>
<header>
Sign In
</header>
<fieldset>
<section>
<label class="label">User</label>
<label class="input"> <i class="icon-append fa fa-user"></i>
<input type="text" name="LoginForm[username]">
<b class="tooltip tooltip-top-right"><i class="fa fa-user txt-color-teal"></i> Escribe tu …Run Code Online (Sandbox Code Playgroud) 我最近在远程存储库中推送了项目更改的提交。我刚刚发现我通常不提交更改的文件之一被包含在内,因为它可能包含敏感信息。
我想撤消对该文件的提交更改(到最后一个状态),而不丢失其他文件中提交的更改。
由此:
对此:
目前,只有我有权访问该存储库,因此重写历史记录没有问题,因此当我授予对该远程存储库的访问权限时,他们不会在历史记录中看到敏感信息。那么,我该怎么做呢?
我知道,编译编译器很讽刺.但我需要这个编译器的特定版本,而CentOS 5.x存储库没有最新版本的GCC.
我需要的版本是4.3.2但我只有4.1.1.
我按照本教程安装了gcc http://www.mjmwired.net/resources/mjm-fedora-gcc.html,我在configure(编译前)中使用了以下参数:
/root/gcc/gcc-4.3.6/configure --prefix =/opt/gcc43 --program-suffix = 43 --enable-languages = c,c ++ --enable-shared --enable-threads = posix - disable-checking --with-system-zlib --enable -__ cxa_atexit --disable-libunwind-exceptions --disable-multilib
最后一个选项--disable-multilib保存我在之前的编译尝试中得到的另一个错误(经过长时间的编译...)
另外我设置了一个环境变量,因为在以前的尝试中,我有错误,所以我设置如下:
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib:$LD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)
这可以确保编译器在该目录中搜索mpfr和gmp库(需要它们)
所以,我执行'make'命令.
我虽然一切都还好,因为这段时间花了更多时间(在我设置该变量之前的最后一次尝试花了我2个小时编译)
我在Amazon Web Services中使用了Micro实例,这个实例只有1个单核x86_64处理器和613 MB RAM,因此编译需要大约9个小时.
不幸的是,我又错了!!,现在我得到了这个:
make[2]: Entering directory `/root/gcc/build'
make[3]: Entering directory `/root/gcc/build'
rm -f stage_current
make[3]: Leaving directory `/root/gcc/build'
Comparing stages 2 and 3
warning: ./cc1-checksum.o differs
warning: ./cc1plus-checksum.o differs
Bootstrap comparison failure!
./gcc.o differs
./varasm.o differs
./except.o differs
./i386.o …Run Code Online (Sandbox Code Playgroud) 我已经安装了RVM,然后安装了Jruby,这是我输入的版本:jruby -v:
jruby 1.6.5.1(ruby-1.8.7-p330)(2011-12-27 1bf37c2)(Java HotSpot(TM)Client VM 1.7.0_02)[linux-i386-java]
问题是我无法安装therubyracer gem,当我尝试通过jruby -S gem install therubyracer安装时,我得到了这个:
/usr/local/rvm/rubies/jruby-1.6.5.1/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library very we$
Check http://kenai.com/projects/jruby/pages/Home for alternatives.
Checking for Python...Unable to build libv8: Python not found!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include …Run Code Online (Sandbox Code Playgroud) 我有一个具有以下参数的函数:
<cffunction name="Agregar" access="public" returntype="any">
<cfargument name="id_examen" type="numeric" required="yes" />
<cfargument name="id_tema" type="numeric" required="yes" />
<cfargument name="id_tipopregunta" type="numeric" required="yes" />
<cfargument name="id_dificultad" type="numeric" required="yes" />
<cfargument name="opciones_arreglo" type="array" required="no" />
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用cfif来说明当没有收到参数"opciones_arreglo"时该怎么做.我使用了一个名为的函数isDefined,但它不起作用.我只想让代码运行其他部分,但我得到了关于显而易见的事情的抱怨:
Element OPCIONES_ARREGLO is undefined in ARGUMENTS.
The error occurred in C:\www\htdocs\RHRR\componentes\bro\preguntas.cfc: line 24
22 : <cfdump var="#Arguments#">
23 :
24 : **<cfif IsDefined(Arguments.opciones_arreglo)>**
25 :
26 : <cfinvoke method = "RSAgregar"
Run Code Online (Sandbox Code Playgroud) 我想在两个布局之间添加一条分隔线:
Separador = QFrame()
Separador.Shape(QFrame.HLine)
Separador.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding)
Separador.setLineWidth(3)
HPOUT1_layout = QVBoxLayout()
HPOUT1_layout.addLayout(HPOUT1L_layout)
HPOUT1_layout.addWidget(Separador)
HPOUT1_layout.addLayout(HPOUT1R_layout)
Run Code Online (Sandbox Code Playgroud)
然而,这段代码只是将布局分开了一点,但它们之间没有可见的线。还有其他方法吗,我做错了什么?
我有一个项目正在使用(我假设).NET Core.我有一个存储安全密钥对值的库.键是字符串,值应该是byte [],所以我必须将我想要存储的字符串转换为byte []:
bytes[] my_bytes = Encoding.Unicode.GetBytes(txtSomeInfo.Text)
Run Code Online (Sandbox Code Playgroud)
问题是当我检索值时,因为是一个byte []数组我应该将它转换回字符串,如下所示:
my_string = Encoding.Unicode.GetString(my_bytes)
Run Code Online (Sandbox Code Playgroud)
我在Stack Overflow中找到了一些答案,但是......我不能像那样使用它,因为System.Text.Encoding的这个版本的GetString方法要求两个额外的参数: int index, and int count
我怎样才能收回我的字符串?
我有一个有对象的数组,这些对象有一个字符串,一个整数和一个char属性.
Person[] people = new Person[1]; //Declare the array of objects
[...] This code is irrelevant
Person person = new Person(name, age, gender); //This creates instance a new object
people.SetValue(person, i); //is just a variable which increase in a c
Array.Resize(ref people, people.Length + 1); //Change array size
i++; // Autoincrement
Run Code Online (Sandbox Code Playgroud)
[...]更多代码来填充有效的值
从人数组中存储的所有对象中,我想得到人的年龄最大值(年龄属性是整数值)
我正在将两个小部件(两个按钮)之间的线绘制到图形视图中,并将它们的位置作为参考。但是这条线画错了地方。
我尝试使用类似mapToGlobal或mapToParent具有不同结果的函数,但它仍然是错误的。在同一个班级中,我有另一种用鼠标画线的方法,它工作正常。我把它当作参考,但似乎事件位置具有不同的坐标系。我不知道为什么会这样。
按钮和图形视图位于 Widget 内,该 Widget 也位于窗口内。
这是类:
from PyQt4 import QtGui, QtCore
class WiringGraphicsView(QtGui.QGraphicsView):
def __init__(self, parent):
QtGui.QGraphicsView.__init__(self, parent)
self.setScene(QtGui.QGraphicsScene(self))
#self.setSceneRect(QtCore.QRectF(self.viewport().rect()))
def mousePressEvent(self, event):
self._start = event.pos()
def mouseReleaseEvent(self, event):
start = QtCore.QPointF(self.mapToScene(self._start))
end = QtCore.QPointF(self.mapToScene(event.pos()))
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0) )
pen = QtGui.QPen(brush, 2)
line = QtGui.QGraphicsLineItem(QtCore.QLineF(start, end))
line.setPen(pen)
self.scene().addItem( line )
def paintWire(self, start_widget, end_widget):
start_position = QtCore.QPointF(self.mapToScene(start_widget.pos()))
end_position = QtCore.QPointF(self.mapToScene(end_widget.pos()))
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0) )
pen = QtGui.QPen(brush, 2)
line …Run Code Online (Sandbox Code Playgroud) 我需要一个通过 REST 提供 PDF 的 WCF 服务库。例如,我有一个像这样的网址:localhost:8732/service1/reports/ok
我收到一个 PDF 作为响应。它是本地文件系统中的固定文件。这是我当前的代码:
服务.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfJsonRestService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class Service1 : IService1
{
public Stream GetReport(string value)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "application/pdf";
FileStream f = new FileStream("C:\\invoice.pdf", FileMode.Open);
int …Run Code Online (Sandbox Code Playgroud)