草庐IT

system.json

全部标签

c# - 如何强制 WebAPI 使用 JSON.net 6.0.3 而不是 4.5?

添加WebAPI并在Global.asax中注册后。我们发现我们的网络应用程序在这一行中断:Line17:GlobalConfiguration.Configure(WebApiConfig.Register);错误信息:Couldnotloadfileorassembly'Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed'oroneofitsdependencies.Thesystemcannotfindthefilespecified.经过一些检查,我发现我们在这个MVC5

c# - System.Net.ProtocolViolationException : You must write ContentLength bytes to the request stream before calling [Begin]GetResponse

我得到了"System.Net.ProtocolViolationException:YoumustwriteContentLengthbytestotherequeststreambeforecalling[Begin]GetResponse"errorwhencallingtothe"BeginGetResponse"methodofthewebrequest.这是我的代码:try{StreamdataStream=null;WebRequestWebrequest;Webrequest=WebRequest.Create(this.EndPointAddress);Webrequ

c# - Rx.NET 的 System.CoreEx.dll 在哪里

这似乎是一个愚蠢的问题,但我从这里下载了.NET的ReactiveExtensions:http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx这个简单的例子给我一个构建错误:vartest=new[]{1,2,4,5};test.ToObservable().Subscribe(Console.WriteLine);编译器说:Error2Thetype'System.Concurrency.IScheduler'isdefinedinanassemblythatisnotreferenced.Youmustaddareferencet

c# - ASP.NET Core 中的 System.Data.Entity.Spatial 替换

我正在尝试将Web表单从ASP.NETMVC迁移到ASP.NETCoreMVC。目前我正在尝试找到一种方法来替换:usingSystem.Data.Entity.Spatial;因为它目前在.NETCore中不可用,或者我可能找不到它。有没有办法包含这个包?也许通过NuGet包?附言。我简要阅读了Microsoft指南,但找不到与之相关的任何内容。对于任何可能处于类似情况的人,指南在这里:https://docs.asp.net/en/latest/migration/mvc.html(对不起,如果我不能写出一个好问题,我正在努力适应这里的系统) 最佳答案

C# - System.Transactions.TransactionScope

我对TransactionScope类很好奇。在大多数情况下,我假设它是用于数据库连接(这就是我用它的目的)。我的问题是,您能否将任何代码放入TransactionScope的usingblock中以使其具有事务性?MS文档对此并不清楚。如果它可以用于使除数据库连接之外的代码成为事务性的,那么支持哪些代码?如果它可以使System.IO.File操作具有事务性,这对我来说似乎很疯狂。 最佳答案 TransactionScope不仅适用于数据库。每个实现IEnlistmentNotification接口(interface)的组件都可

c# - 将 .Net 对象序列化为 json,使用 xml 属性控制

我有一个.Net对象,我一直在将其序列化为Xml,并使用Xml属性进行装饰。我现在想将同一个对象序列化为Json,最好使用NewtonsoftJson.Net图书馆。我想直接从内存中的.Net对象转到Json字符串(无需先序列化为Xml)。我不希望向该类添加任何Json属性,而是希望Json序列化程序使用现有的Xml属性。publicclassworld{[XmlIgnore]publicintignoreMe{get;}[XmlElement("foo")]publicintbar{get;}[XmlElement("marco")]publicintpolo{get;}}成为{"f

c# - 如何在 json.net 中将空字符串反序列化为枚举

我正在将json属性反序列化为一个枚举,但是当属性为空字符串时,我在处理情况时遇到了问题。Errorconvertingvalue""totype'EnrollmentState'我正在尝试反序列化requiredItem中的state属性。{"currentStage":"Pre-Approved","stages":["Applicant","Pre-Approved","Approved","Enrolled"],"requiredItems":[{"id":1,"name":"Documents","state":""},{"id":2,"name":"EligibilityV

c# - 在 json 和 Web api 之间保持 C# datetime 本地时间?

当我在json对象中有数据时间时遇到问题,它将在C#dateTime中将其转换为UTC时区只是想问一下如何保持本地时间?我可以在web.config文件或geter或setter中设置时区属性,因为我必须反对有日期和时间吗?这是类示例?publicclassPatient{publiclongRecordId{get;set;}publicstringUsername{get;set;}publicDateTimeDate{get;set;}publicboolDeleted{get;set;}publicstringModifiedBy{get;set;}publicDateTime

c# - 反序列化具有以数字开头的某些属性名称的json

JSON数据看起来像这样[{"market_id":"21","coin":"DarkCoin","code":"DRK","exchange":"BTC","last_price":"0.01777975","yesterday_price":"0.01770278","change":"+0.43","24hhigh":"0.01800280","24hlow":"0.01752015","24hvol":"404.202","top_bid":"0.01777975","top_ask":"0.01790000"}]注意这里的这3个属性24high、24hhlow和24hvol您

c# - 使用 Json.Net 反序列化时出现错误 "Cannot deserialize the current JSON array"

我有一个字符串:[{"key":"key1","value":"{'Time':'15:18:42','Data':'15:18:42'}","duration":5},{"key":"key1","value":"{'Time':'15:18:42','Data':'15:18:42'}","duration":5}]我的模型类:publicclassCPacket{publicstringkey{get;set;}publicstringvalue{get;set;}publicintduration{get;set;}}我使用Json.Net,我想将下面的字符串转换为Json对象