草庐IT

system-auth

全部标签

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.

c# - System.Timers.Timer/Threading.Timer 与 Thread with WhileLoop + Thread.Sleep 用于周期性任务

在我的应用程序中,我必须定期向“兄弟”应用程序发送心跳。使用System.Timers.Timer/Threading.Timer或使用带有while循环和Thread.Sleep的线程更好吗?心跳间隔为1秒。while(!exit){//doworkThread.Sleep(1000);}或myTimer.Start(()=>{//dowork},1000);//pseudocode(notactualsyntax)... 最佳答案 System.Threading.Timer有我的投票权。System.Timers.Timer旨

c# - 如何测试 MethodInfo.ReturnType 是否为 System.Void 类型?

使用反射获取一个MethodInfo,我想测试返回的类型是否为typeofSystem.Void。测试它是否是System.Int32工作正常myMethodInfo.ReturnType==typeof(System.Int32)但是myMethodInfo.ReturnType==typeof(System.Void)不编译?目前我正在测试名称的字符串表示是否为“System.Void”,这似乎是非常错误的。 最佳答案 您不能使用System.Void直接,但可以使用typeof(void)访问它.一些人指出(例如here和评论

c# - EntityFramework.dll 中出现类型为 'System.TypeInitializationException' 的未处理异常

我正在努力学习EntityFramework和SQLite使用thistutorial.但是,我收到一个错误。抛出的错误是:Anunhandledexceptionoftype'System.TypeInitializationException'occurredinEntityFramework.dllAdditionalinformation:Thetypeinitializerfor'System.Data.Entity.Internal.AppConfig'threwanexception.这是完整的错误跟踪:System.TypeInitializationException