草庐IT

system-tray

全部标签

c# - 更改 System.Uri 的方案

我正在寻找改变给定System.Uri方案的规范方式带有System.UriBuilder的实例没有蹩脚的字符串操作和魔术常量。说我有varuri=newUri("http://localhost/hello")我需要将其更改为“https”。我的问题是有限的UriBuilder构造函数和Uri.Port默认为80(我们应该将其更改为443吗?硬编码?)。代码必须遵守所有Uri属性,例如可能的基本身份验证凭据、查询字符串等。 最佳答案 最后是这个:varuriBuilder=newUriBuilder(requestUrl){Sch

c# - 无法加载文件或程序集“System.Web.Helpers,IIS 8 上的错误

我有一个MVC4Web应用程序,它使用本地IISExpress服务器在VisualStudio2012上运行良好。当我将应用程序发布到在Windows2012上运行的IIS8Web服务器时,初始登录页面显示正确。但是,使用远程调试时,我发现当我使用以下行检查凭据时:if(ModelState.IsValid&&WebSecurity.Login(model.UserName,model.Password,persistCookie:model.RememberMe))我得到如下图所示的错误:(来源:usf.edu) 最佳答案 解决方

c# - MVC : The parameters dictionary contains a null entry for parameter 'k' of non-nullable type 'System.Int32'

我是MVC的新手。在我的应用程序中,我正在从Mydatabase中检索数据。但是当我运行我的应用程序时,它会显示这样的错误这是我的网址http://localhost:7317/Employee/DetailsData/4ExceptionDetails:System.ArgumentException:Theparametersdictionarycontainsanullentryforparameter'k'ofnon-nullabletype'System.Int32'formethod'System.Web.Mvc.ActionResultDetailsData(Int32)

c# - 类型参数 'System.Net.Http.Headers.MediaTypeHeaderValue' 违反了类型参数 'T' 的约束

我有一个WebAPI解决方案(针对.NET4.6),其中包含几个相当轻量级的.NETCore项目。我已将.NETCore项目打包为NuGet包并将它们安装到WebAPI项目。一切构建正常,但在运行它时,在应用程序初始化时出现以下异常。MethodSystem.Net.Http.CloneableExtensions.Clone:typeargument'System.Net.Http.Headers.MediaTypeHeaderValue'violatestheconstraintoftypeparameter'T'.[VerificationException:MethodSyst

c# - “委托(delegate) 'System.Action' 不接受 0 个参数。”这是 C# 编译器错误(lambdas + 两个项目)吗?

考虑下面的代码。看起来像完全有效的C#代码,对吗?//ProjectBusingSystem;publicdelegatevoidActionSurrogate(ActionaddEvent);//publicdelegatevoidActionSurrogate2();//UsingActionSurrogate2insteadofSystem.Actionresultsinthesameerror//Usingadummyparameter(Action)resultsinthesameerror//ProjectApublicstaticclassClass1{publicsta

c# - 如何使用 System.Net.DNS 获取 dns 名称的 mx 记录?

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭去年。Improvethisquestion.NET库中是否有任何内置方法可以返回给定域的所有MX记录?我知道您如何获得CNAMES,但没有MX记录。

c# - 通过 Exchange Online (Office 365) 使用 System.Net.Mail 发送 SMTP 电子邮件

我们正在测试新的Office365测试版,我在ExchangeOnline服务上有一个邮件帐户。现在我正在尝试连接一个可以从我的测试帐户发送smtp电子邮件的LOB应用程序。但是Exchange365平台需要在端口587上进行TLS加密,System.Net.Mail的“功能”不允许隐式SSL加密。有没有人设法让C#通过这个平台发送邮件?我有以下应该发送邮件的基本代码-任何建议将不胜感激。SmtpClientserver=newSmtpClient("ServerAddress");server.Port=587;server.EnableSsl=true;server.Credent

c# - 错误 : No Entity Framework provider found for the ADO. 具有不变名称 'System.Data.SqlClient' 的 NET 提供程序

我最近将一个旧项目中的EntityFramework从版本4或5升级/更新到版本6。现在我得到这个异常:Anexceptionoftype'System.InvalidOperationException'occurredinEntityFramework.dllbutwasnothandledinusercodeAdditionalinformation:NoEntityFrameworkproviderfoundfortheADO.NETproviderwithinvariantname'System.Data.SqlClient'.Makesuretheproviderisreg

c# - System.Web.Caching 或 System.Runtime.Caching 更适合 .NET 4 Web 应用程序

我正在向ASP.NETWeb应用程序添加缓存。这是.NET4,所以我可以使用System.Runtime.Caching命名空间中的类(据我所知,添加它是为了提供与System.Web.Caching中的功能类似的功能,但对于非Web-应用程序。)但由于这是一个网络应用程序,我最好还是使用System.Web.Caching吗?还是较新的System.Runtime.Caching在某些方面更胜一筹? 最佳答案 Microsoft建议将System.Runtime.Caching用于所有缓存目的。看到这个:http://msdn.m

c# - 如何修复 "' System.AggregateException' 出现在 mscorlib.dll 中”

我在调试时收到未处理的异常,程序停止执行。调试器没有向我显示该行,所以我不知道要修复什么。Anunhandledexceptionoftype'System.AggregateException'occurredinmscorlib.dllAdditionalinformation:ATask'sexception(s)werenotobservedeitherbyWaitingontheTaskoraccessingitsExceptionproperty.Asaresult,theunobservedexceptionwasrethrownbythefinalizerthread.