Search Results

Search found 1974 results on 79 pages for 'mfc serialization'.

Page 12/79 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Binary serialization and deserialization without creating files (via strings)

    - by the_V
    Hi, I'm trying to create a class that will contain functions for serializing/deserializing objects to/from string. That's what it looks like now: public class BinarySerialization { public static string SerializeObject(object o) { string result = ""; if ((o.GetType().Attributes & TypeAttributes.Serializable) == TypeAttributes.Serializable) { BinaryFormatter f = new BinaryFormatter(); using (MemoryStream str = new MemoryStream()) { f.Serialize(str, o); str.Position = 0; StreamReader reader = new StreamReader(str); result = reader.ReadToEnd(); } } return result; } public static object DeserializeObject(string str) { object result = null; byte[] bytes = System.Text.Encoding.ASCII.GetBytes(str); using (MemoryStream stream = new MemoryStream(bytes)) { BinaryFormatter bf = new BinaryFormatter(); result = bf.Deserialize(stream); } return result; } } SerializeObject method works well, but DeserializeObject does not. I always get an exception with message "End of Stream encountered before parsing was completed". What may be wrong here?

    Read the article

  • Java serialization problem

    - by stefan89
    I have two classes X and Y, like this: class X implements Serializable { int val1; Y val2; } class Y implements Serializable { int val; } I want to transmit an object of type X from a client to server but i can't because the class X has a field of type Y. I replaced the field of type Y with a field of type X in class X and it works.

    Read the article

  • Desine time XAML serialization problem in VS2010 Designer

    - by Reporting Avatar
    The wired problem is, in VS 2008, everything works fine. In VS2010 while serializing, it is missing the "ReportDimensionElements" so I'm unable to get the values back from the serialized value back from the XAML. It says, "'ReportDimensionElements' is null" am I missing anything silly. Note: I have marked the ReportDimensionElements class with [DefaultValue(null)] for avoiding {x:Null} being serialized. Will it be causing this by any way? Serialized XAML .Net 3.5 <Report> <Report.CategoricalAxis> <CategoricalAxis> <CategoricalAxis.ReportDimensionElements> <ReportDimensionElements Capacity="4"> <ReportDimensionElement DimensionName="Customer" HierarchyName="Customer Geography" LevelName="Country" /> </ReportDimensionElements> </CategoricalAxis.ReportDimensionElements> </CategoricalAxis> </Report.CategoricalAxis> </Report> .Net 4.0 <Report> <Report.CategoricalAxis> <CategoricalAxis> <CategoricalAxis.ReportDimensionElements> <ReportDimensionElement DimensionName="Customer" HierarchyName="Customer Geography" LevelName="Country" /> </CategoricalAxis.ReportDimensionElements> </CategoricalAxis> </Report.CategoricalAxis> </Report> Great Thanks

    Read the article

  • ASP webservice serialization of properties

    - by badra
    I got a class like this which gets returned from an ASP webservice: class Data { public int A { get; set; } public int B { get; set; } public int Sum { get { return A + B; } } } When I try to consume the webservice on the client side using Silverlight I only get the properties A and B but I also need Sum. I know I can't return any logic from a webservice, so the expected behavior was it will return the the Sum as a fixed/precalculated property in the client which is what I need. Any ideas except for redesigning my class? Thanks ...

    Read the article

  • Why do we need serialization in web service

    - by Cloud2010
    I have one webservice: public class Product { public int ProductId { get; set; } public string ProductName { get; set; } } public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public List<Product> GetItems() { List<Product> productList = new List<Product>() { new Product{ProductId=1,ProductName="Pencil"}, new Product{ProductId=2,ProductName="Pen"} }; return productList; } and in a asp.net application I am consuming it like: localhost.Service s = new localhost.Service(); List<localhost.Product> k = new List<localhost.Product>(); k = s.GetItems().ToList(); // i am getting the values here. now my question is do I need to serialize my webmethod as i am returning custom types? when should we serialize ? is it necessary at all, if yes , then what are the conditions?

    Read the article

  • Fast serialization/deserialization of structs

    - by user256890
    I have huge amont of geographic data represented in simple object structure consisting only structs. All of my fields are of value type. public struct Child { readonly float X; readonly float Y; readonly int myField; } public struct Parent { readonly int id; readonly int field1; readonly int field2; readonly Child[] children; } The data is chunked up nicely to small portions of Parent[]-s. Each array contains a few thousands Parent instances. I have way too much data to keep all in memory, so I need to swap these chunks to disk back and forth. (One file would result approx. 2-300KB). What would be the most efficient way of serializing/deserializing the Parent[] to a byte[] for dumpint to disk and reading back? Concerning speed, I am particularly interested in fast deserialization, write speed is not that critical. Would simple BinarySerializer good enough? Or should I hack around with StructLayout (see accepted answer)? I am not sure if that would work with array field of Parent.children. UPDATE: Response to comments - Yes, the objects are immutable (code updated) and indeed the children field is not value type. 300KB sounds not much but I have zillions of files like that, so speed does matter.

    Read the article

  • Javascript serialization

    - by John
    Have I any chance to serialize meta (any format, so I can store it in DB)? var obj1 = {}; var obj2 = {}; obj1.link = obj2; obj2.link = obj1; var meta = [obj1, obj2]; As I understand the problem is that JSON serialize object`s links to objects.

    Read the article

  • Serialize a generic collection specifying element names for items in the collection

    - by mdresser
    I have a simple class derived from a generic list of string as follows: [Serializable] [System.Xml.Serialization.XmlRoot("TestItems")] public class TemplateRoleCollection : List<string> { } when I serialize this, I get the following XML: <TestItems> <string>cat</string> <string>dog</string> <string>wolf</string> </TestItems> Is there any way to override the xml element name which is used for serializing items in the collection? I would like the following xml to be produced: <TestItems> <TestItem>cat</TestItem> <TestItem>dog</TestItem> <TestItem>wolf</TestItem> </TestItems>

    Read the article

  • Can I serialize a BitArray to XML?

    - by SimonNet
    Hello I have a business class which I need to serialize to xml. It has a BitArray property. I have decorated it with [XmlAttribute] but the serialization is failing with To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Boolean) at all levels of their inheritance hierarchy. System.Collections.BitArray does not implement Add(System.Boolean). I am not sure whether its possible to serialize to xml? If not what would be an efficient means of serializing the BitArray Thanks for looking

    Read the article

  • Deserializing JSON in WCF throws xml errors in .Net 4.0

    - by Syg
    Hi there. I'm going slidely mad over here, maybe someone else can figure out what's going on here. I have a WCF service exposing a function using webinvoke, like so: [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "registertokenpost" )] void RegisterDeviceTokenForYoumiePost(test token); The datacontract for the test class looks like this: [DataContract(Namespace="Zooma.Test", Name="test", IsReference=true)] public class test { string waarde; [DataMember(Name="waarde", Order=0)] public string Waarde { get { return waarde; } set { waarde = value; } } } When sending the following json message to the service, { "test": { "waarde": "bla" } } the trace log gives me errors (below). I have tried this with just a string instead of the datatype (void RegisterDeviceTokenForYoumiePost(string token); ) but i get the same error. All help is appreciated, can't figure it out. It looks like it's creating invalid xml from the json message, but i'm not doing any custom serialization here. The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RegisterDeviceTokenForYoumiePost'. Unexpected end of file. **Following elements are not closed**: waarde, test, root.</Message><StackTrace> at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)

    Read the article

  • How to disable WinMain entry point for a MFC application?

    - by Sorin Sbarnea
    I understand that is not possible to have applications with multiple entry points under Windows. I have a MFC application and I added code for making it running as a service (main() entry point and other required stuff) but it looks that Windows will always run the WinMain() from MFC instead of my main. The question is how can I disable the WinMain() from MFC in order to be able to run my own main(). Probably the same problem would apply if you want to run the same application as a console application. What do I have to change in project properties in order to build it as a console application (main instead of WinMain)? Is commenting my CWinApp the only solution?

    Read the article

  • Serialization vs. Marshaling

    Are you somewhat confused between Serialization and Marshaling? This writing would break this confusion up, it would give you a basic understanding of the process of Serialization and the process of Marshaling, and how you can get the most out of each.

    Read the article

  • By knowing VC++ MFC, how easy or difficult is to learn C#.Net?

    - by AKN
    Right now, I'm more into design & maintenance of MFC based application. I'm seeing good progress and requirement for C#.Net application. With this background knowledge, how easy or difficult is to learn C#.Net? Is there any tutorials available online that helps MFC developers to easily learn C#.Net quickly? Any help on this much appreciated!

    Read the article

  • By knowing VC++ MFC, how difficult is to learn C#.Net?

    - by AKN
    Right now, I'm more into design & maintenance of MFC based application. I'm seeing good progress and requirement for C#.Net application. With this background knowledge, how easy or difficult is to learn C#.Net? Is there any tutorials available online that helps MFC developers to easily learn C#.Net quickly? Any help on this much appreciated!

    Read the article

  • Is Java serialization a tool to shrink the memory footprint?

    - by Pentius
    Hey folks, does serialization in Java always have to shrink the memory that is used to hold an object structure? Or is it likely that serialization will have higher costs? In other words: Is serialization a tool to shrink the memory footprint of object structures in Java? Edit I'm totally aware of what serialization was intended for, but thanks anyway :-) But you know, tools can be misused. My question is, whether it is a good tool to decrease the memory usage. So what reasons can you imagine, why memory usage should increase/decrease? What will happen in most cases?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >