15,887,596 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Saeed Jafarian (Top 27 by date)
Saeed Jafarian
12-Aug-15 11:34am
View
ok, thank you for your helps
Saeed Jafarian
12-Aug-15 11:31am
View
i use this article for my codes
http://www.codeproject.com/Articles/422474/Serialization-using-different-formats-in-NET
and i need server.mappath because it is a website project
Saeed Jafarian
12-Aug-15 11:26am
View
no i get just one file for course list<>.
the point is i am deserializing the xml to the list without problem, even with the database and encoding i could deserialize. but the reference is broken between object.
Saeed Jafarian
12-Aug-15 11:07am
View
ok now i do it with fileStream
serializing:
DataContractSerializer CourseSerializer = new DataContractSerializer(typeof(List<'course'>), null, int.MaxValue, false, true /* preserveObjectReferences */, null);
XmlDictionaryWriter writer = null;
FileStream fs = null;
fs = new FileStream(Server.MapPath("course.xml"), FileMode.Create);
writer = XmlDictionaryWriter.CreateTextWriter(fs);
CourseSerializer.WriteObject(writer, Courses);
writer.Close();
fs.Close();
deserializing:
FileStream fs = null;
DataContractSerializer ser = null;
XmlDictionaryReader reader = null;
fs = new FileStream(Server.MapPath("course.xml"), FileMode.OpenOrCreate);
reader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
ser = new DataContractSerializer(typeof(List<course>));
Courses = (List<'course'>)ser.ReadObject(reader);
fs.Close();
reader.Close();
and do it for level and prof list either
no database, no encoding, just stream, but the problem not solved....
Saeed Jafarian
12-Aug-15 9:52am
View
here i upload the xml output for a simple run of the application for consideration
http://s000.tinyupload.com/?file_id=01744593121547335786
Saeed Jafarian
12-Aug-15 9:45am
View
Deleted
and this is the simple output of the serialization:
<arrayofcourse xmlns="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:id="1" z:size="2">
<course z:id="2">
<departmanid>1
<departmanname z:id="3">dep1
<facultyid>3
<facultyname z:id="4">fac1
<coursecode>35346
<coursefield z:id="5">
<courseperweek>2
<coursetype z:id="6">تئوري
<exceptioninstring z:ref="5" i:nil="true">
<id>0
<capacity>50
<coursename z:id="7">الگوريتم
<department i:nil="true">
<departmentplace>true
<distancepart>0
<duration>2
<exception_slots xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" z:id="8" z:size="0">
<faculty i:nil="true">
<facultyplace>false
<level i:nil="true">
<oneday>true
<professor z:Id="9">
<departmanid>0
<departmanname i:nil="true">
<facultyid>0
<facultyname i:nil="true">
<ProfId>2</ProfId>
<teachingcourses z:id="10" z:size="2">
<course z:id="11">
<departmanid>1
<departmanname z:ref="3" i:nil="true">
<facultyid>4
<facultyname z:ref="4" i:nil="true">
<coursecode>2354
<coursefield z:ref="5" i:nil="true">
<courseperweek>2
<coursetype z:id="12">تئوري
<exceptioninstring z:ref="5" i:nil="true">
<id>0
<capacity>50
<coursename z:id="13">درس1
<department i:nil="true">
<departmentplace>true
<distancepart>0
<duration>2
<exception_slots xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" z:id="14" z:size="0">
<faculty i:nil="true">
<facultyplace>false
<level i:nil="true">
<oneday>true
<professor z:Ref="9" i:nil="true" />
<projection>false</projection>
<sameclass>false
<sameday>false
<sameslot>false
<course z:ref="2" i:nil="true">
<teachingprogram xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" z:size="0">
<profName z:Id="15">استاد 1</profName>
</professor>
<projection>false</projection>
<sameclass>false
<sameday>false
<sameslot>false
<course z:ref="11" i:nil="true">
<arrayofprof xmlns="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:id="1" z:size="1">
<prof z:Id="2">
<departmanid>0
<departmanname i:nil="true">
<facultyid>0
<facultyname i:nil="true">
<ProfId>2</ProfId>
<teachingcourses z:id="3" z:size="2">
<course z:id="4">
<departmanid>1
<departmanname z:id="5">dep1
<facultyid>4
<facultyname z:id="6">fac1
<coursecode>2354
<coursefield z:id="7">
<courseperweek>2
<coursetype z:id="8">تئوری
<exceptioninstring z:ref="7" i:nil="true">
<id>0
<capacity>50
<coursename z:id="9">درس1
<department i:nil="true">
<departmentplace>true
Saeed Jafarian
12-Aug-15 7:43am
View
Hello again
i did serialize and deserialize with dataContractSerializer but the problem still exists,
what i have done:
<pre lang="cs">
XmlDocument SerialedCourse = new XmlDocument();
DataContractSerializer CourseSerializer = new DataContractSerializer(typeof(List <'course'> ), null, int.MaxValue, false, true /* preserveObjectReferences */, null);
using (MemoryStream courseStream = new MemoryStream())
{
CourseSerializer.WriteObject(courseStream, Courses);
courseStream.Position = 0;
SerialedCourse.Load(courseStream);
}
</pre>
and then insert it into the sql table with xml column, i checked the result and i think the refrencing exist beacause i see something like <professor z:Id="9"> in the course array list, but i dont know why after deserialization that problem not solved,
for deserialization i used something like:
string temp = dt_load.Rows[0][1].ToString();
byte[] byteArray = Encoding.UTF8.GetBytes(dt_load.Rows[0][1].ToString());
MemoryStream courseStream = new MemoryStream(byteArray);
DataContractSerializer CourseSerializer = new DataContractSerializer(typeof(List <'course'> ));
Courses = (List<'course'>)CourseSerializer.ReadObject(courseStream);
i am totally confused
Saeed Jafarian
11-Aug-15 13:27pm
View
so if i use DataContractSerializer the problem should be solved , i don`t have problem with switching , i have tried 3 types of serializer up to now.
i will try and make you know if this works
Saeed Jafarian
11-Aug-15 13:14pm
View
thank you for your contribution,yes, you are right
Saeed Jafarian
11-Aug-15 13:08pm
View
thank you for your comment, yes, this is exactly the issue,but i dont understand how to solve it, how you manually reference them after deserialization?
Saeed Jafarian
11-Aug-15 12:26pm
View
i used newtonsoft json.net which support cycles
Saeed Jafarian
11-Aug-15 12:24pm
View
there is no other class further , i had shown what i mean by other class : like prof class , like course class. and yes it has cycle, the prof has course and course has prof then yes, it has cycle but i used protobuf or binary formatter and yet this problem exist. what about that?
Saeed Jafarian
25-May-15 9:02am
View
...........................................................................
Saeed Jafarian
9-Sep-14 15:15pm
View
thank you very much for your help
Saeed Jafarian
9-Sep-14 15:02pm
View
yeees you are right , in my insert query and my connection class the parameters are changed to string and that was the problem, so i fix them and the serialize part work as well which i should thank you very much , your answers was very helpful and i appreciate you
but now i get error in deserialize that means i cannot cast the right side to the left side
this line:
List<departman> dep =(List<departman>)formatter.Deserialize(departmanStream);
any ideas?
Saeed Jafarian
9-Sep-14 14:09pm
View
your right, my fault, sorry
Saeed Jafarian
9-Sep-14 14:07pm
View
now i get the error :
The input stream is not a valid binary format. The starting contents (in bytes) are: 53-00-79-00-73-00-74-00-65-00-6D-00-2E-00-42-00-79 ...
which i think there is something wrong with my serialize part, which i explain in the answer to your comment above
Saeed Jafarian
9-Sep-14 14:02pm
View
do i have a choice here?
i get the data from the database with a select query and put them to the DataTable which of course changes it to string, what do you suggest i should do?
and as i mentioned in first comment:
i also think there is something wrong with my serialize part because when i see my database records all of the columns and rows are the same as each other despite the different list<> objects
Saeed Jafarian
9-Sep-14 13:50pm
View
i mentioned in the last comments that the columns type are varbinary(MAX) and the GenerateStreamFromString method is mentioned in the question itself but that`s it:
public Stream GenerateStreamFromString(string s)
{
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
Saeed Jafarian
9-Sep-14 13:33pm
View
oh i am so sorry i did not copy these two lines :
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(departmanStream, Departments);
and the departments is the list<>
Saeed Jafarian
9-Sep-14 13:22pm
View
i am sorry
can you explain more about "The length of the byte array, DB, should be 0." ? what do you mean exactly?
Saeed Jafarian
9-Sep-14 13:05pm
View
in deserialize part line
:List<departman> dep = (List<departman>)formatter.Deserialize(departmanStream); exception : "End of Stream encountered before parsing was completed"
and i also think there is something wrong with my serialize part because when i see my database records all of the columns and rows are the same as each other despite the different list<> objects, the columns of the DB is varbinary(MAX) to save binary data
and yes the connection is the class of my own which i write to connect to the database with just giving name of the query and the parameters
Saeed Jafarian
22-Aug-12 5:15am
View
this is the error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 209.190.121.56:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at sendnewsletter.btnsend_Click(Object sender, EventArgs e)
Saeed Jafarian
22-Aug-12 5:15am
View
this is the error :
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 209.190.121.56:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at sendnewsletter.btnsend_Click(Object sender, EventArgs e)
Saeed Jafarian
19-Aug-12 12:25pm
View
the real problem is how to assign the category items when "category" is not static, it changes through the repeater1
Saeed Jafarian
12-Aug-11 9:31am
View
the link says: content not found
and i know DateTimePicker is so much better but in this situation i should use maskedtextbox :((
Saeed Jafarian
12-Aug-11 9:28am
View
I checked that before, not help
Show More