我必须编写一个集中式日志框架.
基本要求是:
我做了一些阅读,看起来NLog是最简单的选项和我需要的大多数功能.我的计划是围绕NLog编写一个包装类库,并在我的所有asp.net应用程序,web api以及其他库项目和一些使用COM +的经典asp站点中使用我的库.
但我注意到有些人提到使用ELMAH进行异常处理,NLog进行诊断.
我的问题(或者我应该说是混乱):如果我使用NLog,为什么我会使用ELMAH?
或者什么时候会使用ELMAH和NLog一起使用?
要么
注意我并不是要逐个功能地比较功能,而是想要理解:当一个人选择一个而不是其他人时会出现什么情况?除了ELMAH用于Web应用程序的事实.
没解决 - 仍在寻找解决方案.
我正在通过SAML令牌传入WCF调用:
private static string serviceEndpoint = "https service endpoint";
public static void CallProviderService(SecurityToken token)
{
var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.EstablishSecurityContext = false;
binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;
var channelFactory = new ChannelFactory<ISomeProviderService>(binding, new EndpointAddress(new Uri(serviceEndpoint)));
string thumb = "mycertthumbprint";
channelFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, thumb);
channelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerOrChainTrust;
channelFactory.ConfigureChannelFactory();
channelFactory.Credentials.SupportInteractive = false;
var elements = service.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
service.Endpoint.Binding = new CustomBinding(elements);
var channel = channelFactory.CreateChannelWithIssuedToken<ISomeProviderService>(token);
try
{
var response = channel.MyServiceMethod(somedataobject);
}
catch (Exception ex)
{
//log …Run Code Online (Sandbox Code Playgroud) TFS 2013 - Build:ASP.Net 4.5.1网站我收到此错误:
warning MSB3268: The primary reference "C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll"
could not be resolved because it has an indirect dependency on the framework assembly
"System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which
could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.1". To resolve this problem, either remove the reference
"C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll" or retarget your application to a framework
version which contains "System.Runtime, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a".
Run Code Online (Sandbox Code Playgroud)
最初使用Unity 1.0.0.0的所有项目和站点都是4.0.我将其升级到4.5.2.此外,上述错误中的MyProj1引用了Unity,我也将其升级到3.5.1.
阅读本文:https://unity.codeplex.com/workitem/12756 构建服务器已在变通方法中指向更新的4.5.2.
所以我降级到4.5.1,但仍然得到错误.
解决方案通过Visual Studio 2013在本地构建良好.
该独立的类库项目建设TFS正常,但当的Myproj被添加到我的网站的参考,当它失败的.
有任何想法吗?
在升级时,我是否需要除TragetFramework settign之外的任何web.config更改?
对于下面的代码,我想在"折扣"和500美元之间添加间距.我不希望添加额外的休息标签.这是jsbin上的示例.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Spacing Test</title>
<style type="text/css">
.labelReadOnlyTB {
font-size: 16px;
font-family: Arial;
padding: 1px;
}
.labelForTextbox
{
font-weight: bold;
font-size: 12px;
color: #000000;
font-family: Arial;
padding:8px 0px;
margin-bottom:5px;
}
</style>
</head>
<body>
<table>
<tr>
<td style="min-height:45px;vertical-align:top;">
<span id="lblDiscount" class="labelForTextbox">Discount</span>
<br />
<span id="lblValue" class="labelReadOnlyTB">$500</span>
</td>
</tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我有一个简单的webforms网站项目.该项目使用通过NuGet添加的Microsoft Application Block Unity 3.5(DI Container).
现在我正在使用这个第三方Web服务.在我添加服务引用和构建后,我得到了这个:
错误19 Reference.svcmap:无法加载文件或程序集"Microsoft.Practices.ServiceLocation,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)App_WebReferences/MyExternalService /
所以我安装了Microsoft.Practices.ServiceLocation但它仍然抱怨该程序集.

我尝试将此添加到我的web.config但仍然无法正常工作.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
Run Code Online (Sandbox Code Playgroud)
一旦我卸载Unity包,一切都很好.没有错误,我可以使用服务代理
尝试清洁构建等,但没有任何作用.
任何的想法?
我有一个在ASP.NET 2.0 WebForms中开发的小应用程序.出于学习目的,我正在考虑将此应用程序转换为MVC 3 + Entity Framework.下面是模拟我的应用程序的最简单示例.没有什么花哨.
应用布局:
(图像应为"输入字段"而不是"文件")

建筑:

关键点:
Service层中的SqlCommand ExecuteReader方法是使用ADO.NET 方法执行存储过程
大多数操作等逻辑都是在存储过程中完成的.在Service层中几乎没有任何数据操作
现在我想将此应用程序转换为MVC.
问题:
如果我将此应用程序转换为MVC +实体框架,我(技术上)会获得什么好处?
我该怎么办呢?
我已经看了一些基本的MVC3教程,但他们都讨论了EF代码优先,我认为这不符合我的情况,因为我想使用现有的存储过程.那是对的吗?
注意:我想使用现有的存储过程.假设我无法控制数据库结构的变化.
更新1:
我的应用程序中没有单个内联查询.即使是最小的小查询也是存储过程.他们的吨.
使用SQL Server几乎没有机会更改为任何其他DBS.
更新2:
我的webforms应用程序已完成99%,可以随时上线,但由于一些业务障碍,它没有.同时我想如果我可以将其转换(即开发)到MVC,我将学习加上如果它能够实现(我的第一个MVC)而不是webforms.
我在VSS中有以下项目结构

现在在Visual Studio 2010 Pro中:我打开Solution2,然后将Library1添加为外部项目.
Library1引用了两个我通过NuGet获得的外部库.当我构建我的Solution2时,一切正常.所以我签了我所有的项目.
问题: 当另一个开发人员从sourcesafe和build获得Solution2时,它说Library1缺少那些外部库dll.
试过以下:
1:http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages
所以现在我在Solution2下面有.nuget文件夹,它会被签入.但这仍然没有带来dll.
我怀疑是Library1处于一个单独的解决方案中导致了这个问题.
任何想法如何通过NuGet自动丢失包?
更新:
Xavier的建议有所帮助,这是他的两篇博文:
我正在尝试将 NuGet 包还原与VS2010 + Visual Sourcesafe 一起使用。它部分为我工作。这是从哪里来的:NuGet 没有丢失包

我的 Solution2 有 asp.net 网站[上图中的 Project1],其中安装了另一个 nuget 包。现在另一位开发人员通过VS2010打开了Solution2,Solution1中的库项目自动恢复工作。它获取此 Solution2 中引用的库项目的所有缺失包,我在 Solution1/packages 文件夹中看到它们。
但是对于网站,它说缺少外部 dll,即 pacakages。我认为的问题是因为网站没有 .csproj 文件,所以它不知道需要恢复的东西。(http://nuget.codeplex.com/workitem/1663)
使其部分工作:
将packages/repositories.config 添加到网站解决方案(visual studio 中的解决方案文件夹是什么)
另一位开发人员转到 VSS 并手动获取该包文件夹。现在,当他构建解决方案时,包管理器控制台会提示恢复,即有“恢复”按钮。单击它将带来 AjaxControlToolkit。
问题: - 上述方法是唯一且最好的网站方法吗?
对上述问题有什么想法吗?
这是我的示例代码:
public static class MySqlHelper
{
private static string constring = ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString;
public static int ExecuteNonQuery(string mysqlquery)
{
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(mysqlquery, conn);
int result;
try
{
conn.Open();
result= cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
用法: MySqlHelper.ExecuteNonQuery("select * from customers");
我想知道使用这个静态类的问题.
我可以改变我在这里提到的课程,但我已经在几个网站上使用这个课程,我需要几天时间在每个地方更改它并测试它.
谢谢你的任何投入.
编辑:更新了代码.这会对所提供的答案产生影响吗?对不起,我应该在开头发帖.
我知道.NET Framework 4.0可以单独安装,但是......
.NET Framework 4.0是作为Visual Studio 2010 Professional的一部分安装的,还是VS 2010的安装提示是否完全安装?
如果是单独安装,在VS安装之前或之后安装是否重要?
我想知道这是出于文档目的.我在互联网上的搜索未能取得满意的结果.
编辑:
那么先前的版本(2.0,3.5)呢?它们也安装好了吗?因为VS 2010支持这些版本以及开发.
谢谢你的回答.
我想要跨域JavaScript调用.
1:SiteA:www.sub1.foo.com
2:在SiteA的iframe中打开SiteB:www.bar.com
3:在SiteB中执行某些操作后,通过javascript将一些值从SiteB传递到SiteA.
尝试1: 我按照这篇文章,然后按照#2进行设置.但我不断收到错误:
IE:参数无效
FF:非法的document.domain值.
尝试2: 遵循这篇文章.
它适用于FF.我可以使用window.parent.parent.MyFunction()但在IE中我得到"Permission Denied"错误.
尝试3: 我甚至尝试过window.postMessage技术,但我甚至无法实现这一点.
是否有人成功实施了Cross Domain JS调用上述情况.或任何帮助/链接/建议.
从jQuery 1.4.4迁移到jquery 1.6.4开始破坏与radiobuttonlist相关的代码.
以下是复制奇怪行为的示例代码和步骤:
重现步骤:
1:已选择无线电A.
2:选择无线电B.
3:在文本框中输入内容并标签输出.
您将看到:A已被选中,B被检查警报.
那么究竟从1.6.4变为1.4.4会导致它破裂?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function txtchanged(tb) {
$(".rbl").find("input[type='radio']").each(function () {
alert($(this).val() + " " + $(this).attr("checked"));
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="rbl">
<asp:ListItem Text="A" Value="A" Selected="True" />
<asp:ListItem Text="B" Value="B" />
</asp:RadioButtonList>
<asp:TextBox ID="tb" runat="server" CssClass="tb" onblur="txtchanged(this)"></asp:TextBox>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) asp.net ×5
c# ×2
javascript ×2
jquery ×2
nuget ×2
wcf ×2
.net ×1
.net-4.0 ×1
.net-4.5 ×1
asp.net-mvc ×1
class ×1
cross-domain ×1
css ×1
elmah ×1
firefox ×1
html ×1
logging ×1
nlog ×1
oop ×1
radio-button ×1
static ×1
tfsbuild ×1
web-services ×1
wif ×1