i need to serialize and deserialize an image for my project. i have been googling it for a few days but i cannot find any VB codes related to image serialization... can someone give me some hints on how i should start?? for my program, i need to save the image to sql database and then i need to retrieve all the image for my product catalog
I have a custom Javascript object that has a few string and float members. I'd like to serialize an array of them in Javascript, assign the result to a hidden field, and then retrieve and deserialize them in the codebehind for my asp.net application.
I'm trying to save a custom class in a session, but it just never gets saved, along with other sessions. Note that my SessionMode = STATESERVER, and i cannot change it to INPROC as per our business requirement. This is my class
/*******START*******/ [Serializable] public class User : ISerializable { private int _userId; public int UserId { get { return _userId; } set { _userId = value; } } //custom class private TDB.tdbUser _tdbUserDetails; public TDB.tdbUser tdbUserDetails { get { return _tdbUserDetails; } set { _tdbUserDetails = value; } } //collection of custom class Sites private List<Sites> _assignedSites; public List<Sites> AssignedSites { get { return _assignedSites; } set { _assignedSites = value; } } public User() { //Constructor code } /******SERIALIZATION*****/ protected User(SerializationInfo info, StreamingContext context) { this._userId = (int)info.GetValue("_userId", typeof(int)); this._assignedSites = (List<Sites>)info.GetValue("_assignedSites", typeof(List<Sites>)); this._tdbUserDetails = (TDB.tdbUser)info.GetValue("_tdbUserDetails", typeof(TDB.tdbUser)); } [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("_userId", this._userId); info.AddValue("_assignedSites", this._assignedSites); info.AddValue("_tdbUserDetails", this._tdbUserDetails); } } /*******END*******/
The calling code is just this: (User)HttpContext.Current.Session["TDBUSER"];
From VB.net code behind when I am trying to deserialize it it's stating that
"Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''."
Deserialization code snippet:
Dim serializer = New DataContractJsonSerializer(GetType(List(Of Employee))) Dim memoryStream = New MemoryStream() Dim s = msg.Content.ReadAsString() serializer.WriteObject(memoryStream, s) memoryStream.Position = 0.......
to be able to send a XmlSerializer class (which is generated obvious in remote C# application) over a WebService that will then deserialize it into a class. (I didnt know it its possible either) XmlSerializer mySerializer = new XmlSerializer(typeof(SystemInfo)); StreamWriter myWriter = new StreamWriter(textBox1.Text); mySerializer.Serialize(myWriter, sysinfo); [WebMethod] public void Reports(XmlSerializer xmlSerializer)
I've been struggling with this issue for a while. I'm trying to send an object to the client. Once the client updates the object I'd like to post it back to the server and save it in my database. The first part works fine. However, when I send it back all the dates are messed up and start for year 0001. I assume that's because it can't deserialize the date. Howe can I post a json object with a date property and deserialize it into a type on the server with asp.net mvc 3? group is
public class Group { public Group(); public string CreatedBy { get; set; } public DateTime CreatedOn { get; set; } public string Description { get; set; } public string Name{ get; set; } public string Status { get; set; } public string UpdatedBy { get; set; } public DateTime UpdatedOn { get; set; } } while public JsonResult updateGroup(Group group) { var result = Repository.updateGroup(group); return Json(result, JsonRequestBehavior.AllowGet); }
public class AccessToken { public string access_token {get;set;} public DateTime expires { get; set; } } public class TokenReturn { public List<AccessToken> tokens { get; set; } } JavaScriptSerializer ser = new JavaScriptSerializer(); TokenReturn result = ser.Deserialize<TokenReturn>(responseFromServer);
I am using Json.Net however when I go to deserialize the following json I get that Json cannot deserialize to type List.
Json:
{"postalCodes":[{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10001","countryCode":"US","lng":-73.996705,"placeName":"New York City","lat":40.74838,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10019","countryCode":"US","lng":-73.985834,"placeName":"New York City","lat":40.765069,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10021","countryCode":"US","lng":-73.958805,"placeName":"New York City","lat":40.768476,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10022","countryCode":"US","lng":-73.965703,"placeName":"New York City","lat":40.757091,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10036","countryCode":"US","lng":-73.991826,"placeName":"New York City","lat":40.759724,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10065","countryCode":"US","lng":-73.96379,"placeName":"New York City","lat":40.76507,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10003","countryCode":"US","lng":-73.989223,"placeName":"New York City","lat":40.731253,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10010","countryCode":"US","lng":-73.981328,"placeName":"New York City","lat":40.737476,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10011","countryCode":"US","lng":-73.99963,"placeName":"New York City","lat":40.740225,"adminName1":"New York"},{"adminName2":"New York","adminCode2":"061","adminCode1":"NY","postalCode":"10012","countryCode":"US","lng":-73.998284,"placeName":"New York City","lat":40.72553,"adminName1":"New York"}]}
I have a simple class in asp.net mvc that looks like this:
[code]...
It deserializes it so I have to reference everything by index first, because of the list. So if I had a property called "IsValid" I would have to reference it like this "IsValid[0]". I have way too much javascript code to make these changes.How could I deserialize the JsonResponseItem class so I don't need the index reference in there?
[ServiceContract] public interface IBusiness { [OperationContract][code]....
Add client: [Code]....
But......... the result
Error:The server encountered an error processing the request. The exception message is 'The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'UpdateLanguage'. The token '"' was expected but found '''.'. See server logs for more details. The exception stack trace is:
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest
Im using DataTable to write some XML. but i got Serialization problem. when i try write i got error message, your datatable is not serialize.(i dont want use DataSet)How i Serialize DataTable?
I'm trying to serialize a Request object for logging purposes. The code
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(obj.GetType()); // obj is a Request object
gives me the following exception:To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.String) at all levels of their inheritance hierarchy. System.Web.HttpValueCollection does not implement Add(System.String).
I have a shared object through net remoting. The problem is that this object has some EntitySet and EntityRef attributes. When I try to run the program I get an exception telling me that EntitySet is not marked as Serializable. If I mark it as Serializable everything seems to be ok, but when I try to access from outsied to the attribute represented by the EntitySet, I am not able to use it.
BTW, Does anyone know how change the default binary serialization of tcp channel?
I have no problem getting a custom profile class to work as it should in Asp.Net MVC 2, C# -- as long as I am content that the profile info is serialized as xml.The question is how to get it to serialize as Binary, rather than xml -- Is that possible?in the web.config...
Here I decorated each enum value with [EnumMember], so that I can use the Enum as Data Contract in WCF. And, AppointmentMode will be saved as INTEGER in database. So I need to serialize this Enum to its value. So I have specified value to each member like... [EnumMember(Value = "1")]
Problems:
If I use the above code as it is...SvcUtil not considering Enum Text, and generating the Enum in Proxy as below... [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="AppointmentMode", Namespace="http://www.geniusdoc.portal.com/serivces/2011/v1/GdService")] public enum AppointmentMode: int { [System.Runtime.Serialization.EnumMemberAttribute(Value="1")] _1 = 1, [System.Runtime.Serialization.EnumMemberAttribute(Value="2")] _2 = 2, [System.Runtime.Serialization.EnumMemberAttribute(Value="3")] _3 = 3, } If I remove the Value from [EnumMember(Value = "1")], while deserialization is considering Enum Text, and giving results as below <AppointmentMode>None</AppointmentMode>
Expected result:
1. Enum in the Client proxy should be same original Enum. 2. Enum Deserialization should consider EnumValue, such a way that it will return <AppointmentMode>1</AppointmentMode>
Type 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable
have read all threads but still cant solve the error. I can do insert update and delete but dont know where exactly the error occurs and how??
Currently I am working on SessionState with SQL. I have problem. I would like to serialize TreeNode. This TreeNode pbject will be assigned to Session and this is declare as below.
Is there any way or process to serialize the the objects?? i am trying to store the instance of few control in viewstate but it shows error msg that it is not a serialized object. should i perform some steps to serialize the objects ???