serialization

C# WPF convert BitmapImage pasted in richtextbox to binary

谁都会走 提交于 2019-12-21 04:26:33
问题 I've got a richtextbox, that I plan on saving to a database, which can be loaded back into the same richtextbox. I've got it working so that I can save the flowdocument as DataFormats.XamlPackage, which saves the images, but the issue is that the text isn't searchable. With DataFormats.Xaml, I've got the text of course, but no images. The images will be pasted in by the end user, not images included with the application. I tried using XamlWriter to get the text into XML, and then grab the

Always have error “The ObjectContent 1 type failed to serialize the response body…”

痴心易碎 提交于 2019-12-21 04:22:14
问题 I use Web api to retrieve data from the database. I only have 1 table "tblMessage" and want to get data from that table. I set everything up but then when I run the website. the error always say The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml I read some posts on stackoverflow that sayid the error could be fixed by telling the browser to output data in json format. After that, the error becomes The 'ObjectContent`1' type failed to serialize

Adding durability to in-memory data structures

♀尐吖头ヾ 提交于 2019-12-21 04:06:37
问题 What are some of the popular techniques you can adopt to add durability to your in-memory data structures (ie) if the process crashes, you can preserve all previously executed operations on that data structure? If my data structure involves just a list of tuples, then I would just store them in a SQL DB and that would give me durability for free. But what if my data structure was a graph or a tree? The one thing I could think of is to explicitly log all operations to disk (append-only log)

java+spark: org.apache.spark.SparkException: Job aborted: Task not serializable: java.io.NotSerializableException

旧城冷巷雨未停 提交于 2019-12-21 03:56:19
问题 I'm new to spark, and was trying to run the example JavaSparkPi.java, it runs well, but because i have to use this in another java s I copy all things from main to a method in the class and try to call the method in main, it saids org.apache.spark.SparkException: Job aborted: Task not serializable: java.io.NotSerializableException the code looks like this: public class JavaSparkPi { public void cal(){ JavaSparkContext jsc = new JavaSparkContext("local", "JavaLogQuery"); int slices = 2; int n

Large, Complex Objects as a Web Service Result [closed]

删除回忆录丶 提交于 2019-12-21 03:49:20
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Hello again ladies and gents! OK, following on from my other question on ASP.NET Web Service Results, Proxy Classes and Type Conversion. I've come to a part in my project where I need to get my thinking cap on. Basically, we have a large, complex custom object that needs to be

Jackson SerializationFeature.WRITE_DATES_AS_TIMESTAMPS not turning off timestamps in spring

醉酒当歌 提交于 2019-12-21 03:29:08
问题 After a lot of searching I tracked down how to stop java.util.Date fields from being serialised into timestamps when converting to JSON responses in my @RestController. However I cannot get it to work. All the posts I found said to disable the SerializationFeature.WRITE_DATES_AS_TIMESTAMPS feature of the Jackson objet mapper. So I wrote the following code: public class MVCConfig { @Autowired Jackson2ObjectMapperFactoryBean objectMapper; @PostConstruct public void postConstruct() { this

What are good alternative data formats to XML?

淺唱寂寞╮ 提交于 2019-12-21 03:19:17
问题 XML, granted, is very useful, but can be quite verbose. What alternatives are there and are they specialised for any particular purpose? Library support to interrogate the contents easily is a big plus point. 回答1: There seems to be a lot of multi-platform support for JSON. 回答2: Jeff's article on The Angle Bracket Tax summarizes a number of alternatives (well, mainly YAML), and led me to the wiki article on lightweight markup languages. Update: Although YAML is a possible "alternative to XML"

Constructor not found during deserialization?

泄露秘密 提交于 2019-12-21 03:14:12
问题 Given the following example: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.IO; namespace SerializationTest { [Serializable] class Foo : Dictionary<int, string> { } class Program { static void Main(string[] args) { Foo foo = new Foo(); foo[1] = "Left"; foo[2] = "Right"; BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); formatter.Serialize(stream,

Cannot deserialize the current JSON object, WHY?

耗尽温柔 提交于 2019-12-21 02:54:37
问题 I'm trying to use a WebApi to get a list of Employees from my data base, using this code: This is the code of my client MVC Application: string u = "http://localhost:1411/api/EmployeeAPI"; Uri uri = new Uri(u); HttpClient httpClient = new HttpClient(); Task<HttpResponseMessage> response = httpClient.GetAsync(uri); Task.WaitAll(response); HttpResponseMessage resposta = response.Result; var msg = resposta.Content.ReadAsStringAsync().Result; Employee[] employees = JsonConvert.DeserializeObject

Serialize DateTime as binary

橙三吉。 提交于 2019-12-21 02:34:49
问题 How do I properly serialize a DateTime object (e.g. using a BinaryWriter), and preserve its complete state? I was under the impression that a date time was only represented by an internal long integer, and that this integer was accessible as the Ticks property of the DateTime. However, looking at the implementation, the Ticks property actually returns a subset of the real internal data which is stored in an ulong called dateData Ticks (which just gets InternalTicks) is implemented like so: