我使用Log4net创建了一个简单的场景,但似乎我的appender不起作用,因为消息没有添加到日志文件中.
我将以下内容添加到web.config文件中:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="D:\MyData\Desktop\LogFile.txt" />
<appendToFile value="true" />
<encoding value="utf-8" />
<layout type="log4net.Layout.SimpleLayout" />
</appender>
<root>
<level value="INFO" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
Run Code Online (Sandbox Code Playgroud)
在全局ASAX文件中,我添加了:
ILog logger = LogManager.GetLogger(typeof(MvcApplication));
Run Code Online (Sandbox Code Playgroud)
并在Application_Start方法中:
logger.Info("Starting the application...");
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
这是我第一次使用MySQL作为我的C#应用程序的数据存储,因为我已经看到没有UNIQUEIDENTIFIER类型,因为SQL服务器我决定使用INT与AUTO_INCREMENT,我的问题是现在如果我执行INSERT,怎么可能我得到了刚刚添加的记录的ID.
我快速而又脏的解决方案是执行SELECT MAX(ID)FROM表Statement.但这似乎并不一致.我相信有一个更好的解决方案,如mysql_insert_id()(PHP).
任何想法如何在C#中解决这个问题?
嘿,我是Rails的新手,刚开始按照教程的步骤创建了我的第一个项目.
我使用以下方法创建了新项目:rails myapp.
然后我应该执行bundle install,这不起作用因为尚未安装bundler,在Gems上更新并安装了我已经能够执行的bundle installbundle之后,但每次收到:找不到Gemfile
我检查了我的项目目录,确实没有Gemfile,但是应该自动创建吗?
提前致谢
我尝试使用PHP使用一个简单的Web服务,但是我得到以下错误消息(因为在我看来)说SOAP URL无法打开,但在浏览器中它确实可以正常工作(http://www.webservicex) .NET/uklocation.asmx?WSDL).
任何想法我的错误在哪里?
错误消息:
警告:SoapClient :: SoapClient(http://www.webservicex.net/uklocation.asmx?WSDL)[soapclient.soapclient]:无法打开流:连接在/ home/sia-deutschland_de/www/tests/test中超时第14行的.php
警告:SoapClient :: SoapClient()[soapclient.soapclient]:I/O警告:无法在/ home/sia-deutschland_de/www中加载外部实体"http://www.webservicex.net/uklocation.asmx?WSDL"第14行的/tests/test.php异常错误!
SOAP-ERROR:解析WSDL:无法从'http://www.webservicex.net/uklocation.asmx?WSDL'加载:无法加载外部实体"http://www.webservicex.net/uklocation.asmx? WSDL"
我的代码:
<?php
// include the SOAP classes
require_once('nusoap.php');
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
// Note where 'Get' and 'request' tags are in the XML
//$client = new soapclient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
$err = $client->getError();
if ($err) {
// Display the error
echo 'client construction error: ' . $err ;
} else {
$answer = $client->call(’GetUKLocationByCounty’,
array(
'Country'=>'London')); …Run Code Online (Sandbox Code Playgroud) 我尝试将我的特定域名问题抽象到银行帐户,假设以下情况:
我将类结构设计为folows(简化):
public class Login
{
private List<Account> _bankingAccounts;
....more fields, ctor, getters, setters...
}
public class Account
{
private List<Transaction> _transactions;
....more fields, ctor, getters, setters...
}
public class Transaction
{
String _comment;
....more fields, ctor, getters, setters...
}
Run Code Online (Sandbox Code Playgroud)
好吧,但是如果我说20帐户并且每个都有10000个交易并且我从数据库加载整个模型会有大量内存,甚至我不知道客户是否需要所有这些交易.
我想要构建一个更简化的模型:
public class Login
{
private List<SimpleAccount> _bankingAccounts;
....more fields, ctor, getters, setters...
}
public class SimpleAccount
{
....more fields, ctor, getters, setters...
}
public class Account
{
private List<Transaction> _transactions;
....more fields, ctor, getters, setters... …Run Code Online (Sandbox Code Playgroud) 我创建了一个包含类型列表的类女巫,并派生到我创建的另一个类.这看起来如下:
namespace MyIntegretyCheck.Common
{
/// <summary>
/// Description of PolicyErrors.
/// </summary>
public partial class PolicyErrorEndingDates
{
public int ID_P {get;set;}
public DateTime DT_S_E {get;set;}
public DateTime DT_SC_E {get;set;}
public List<PolicyErrorDescr> Errors {get;set;}
}
public partial class PolicyErrorDescr
{
public string Field1{get;set;}
public string Field2 {get;set;}
public string F1IsThanF2 {get;set;}
public string Message {get;set;}
public int ErrorLevel {get;set;} //0= Info | 1= Warning | 2= Error
}
}
Run Code Online (Sandbox Code Playgroud)
现在我创建了一个类型列表PolicyErrorEndingDates,添加了一个条目,然后尝试添加其嵌套列表错误的条目,如下所示:
public List<PolicyErrorEndingDates> MyPolicyEndingDates()
{
DAL.PolicyEndingDates ped = new DAL.PolicyEndingDates(); …Run Code Online (Sandbox Code Playgroud) 我是Java EE的新手,过去我主要是在.NET上开发的.很快我将开始使用基于Java EE的项目(使用Struts2).我确信有一些方法可以为网站创建一个可以快速更改的模板(类似于ASP.NET中的Masterpages).
有什么解决方案?哪个更受欢迎?
在此先感谢约翰内斯