|
Insert into the DataSource and Refresh() on the DataGrid
|
|
|
|
|
MY program is supposed to send a file asychronously via TCP and sockets, to this end i grab
chunks of the file and store it in a data class, which i serialize and send.This is then
deserialized and the data block is placed in the correct spot in the file by offseting the
stream to the appropriate spot.
ok to the error , this process works the first couple of types with atleast the first 2
chunks of data being recieved and placed in a file on the other side. However after that
things go pear shaped, as once one goes wrong all the remaining chunks no longer work all
giving similar errors.
1 //<< this is my sequence number i use to find offset values
0 //<< current offset in file
got to reciever
got to tryrec
2 //<< this is my sequence number i use to find offset values
1024 //<< current offset in file
got to reciever
got to tryrec
A Exception occured in file transferSystem.Runtime.Serialization.SerializationException: The
input stream is not a valid binary format. The starting contents (in bytes) are:
6C-65-2E-52-65-61-64-4C-69-6E-65-28-29-3B-0D-0A-0D ...
at
System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser
input)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord(
)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream)
at SocketSystem.Program.MessageHandlerServer(CSocketClient pSocket, Int32 iNumberOfBytes)
in c:\documents and
settings\rob\desktop\socketsystem\socketsystem\socketsystem\program.cs:line 274
got to reciever
my data class
[Serializable]<br />
public class DropBear<br />
{<br />
public int SequenceNo = 0;<br />
public string misc = "";<br />
public byte[] buff = null;<br />
<br />
}
---------------------------------------------------------------------------
now for my serialization code
DropBear db = new DropBear();<br />
db.buff = buffered;<br />
db.SequenceNo = filt.currSeqNO++;<br />
BinaryFormatter bf = new BinaryFormatter();<br />
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, db);
Byte[] by = ms.GetBuffer();
//data sent as Byte[] << byte buffer size 10240
//file chunk 1024
----------------------------------------------------------------------------
Deserialization
MemoryStream s = new MemoryStream();<br />
s.Write(pSocket.GetRawBuffer, 0, pSocket.GetRawBuffer.Length);<br />
BinaryFormatter bf = new BinaryFormatter();<br />
s.Position = 0;<br />
DropBear db = (DropBear)bf.Deserialize(s);
-------------------------------------------------------------------
the data is sent with a network stream, i have tryed resetting the buffer at the end of
every read and before every recieve
Any input would be appreciated.
Thanks Rob
|
|
|
|
|
Before reading from the MemoryStream do
ms.Seek(0, SeekOrigin.Begin);
I was getting similar errors. This solved the problem.
|
|
|
|
|
i have a MainForm that act as a MDI container, i load the company logo as backgroundimage, but the image is load as tile mode which fill all the MDI container, is there anyway to set the background image to the center of the MDI container instead of tile?
|
|
|
|
|
the way out is little tricky...
Add another form in your application. Add picture box on it. Assign image in it. then come to your main MDI Form. and in class Declaration inherit it with this new form. and your job is done..
hope this helps
|
|
|
|
|
There is one more trick,
Form f = new Form();
Panel p = new Panel()
f.Controls.Add(p);
p.Dock = DockStyle.Fill;
p.BackGroundImage = //your image
p.BackgroundImageLayout = ImageLayout.Center;
This will work only in VS.NET 2005.
Thanks,
Alomgir
|
|
|
|
|
U could, handling the paint events of the MdiClient control. But isnt easier to just use the designer to drop a picturebox with the logo where u want it instead of using background images?
Maybe I misunderstood ur question.
|
|
|
|
|
hey all,
i have the following code
<code>
public class CustomObjectCollection : CollectionBase
{
...
public int ContainsName(string name)
{
for (int i=0; i<this.Count; i++)
{
if (this[i].Name.Equals(name) { return i; }
}
return -1;
}
...
}
</code>
is there a better way of doing that?
Kids don't try this at home!
|
|
|
|
|
Hi,
I dont see anything wrong with your code.
Seems to be perfect.
Thanks,
Alamgir
|
|
|
|
|
If I get a return from a XML web service, like this : <value>12</value> . How do I retrieve the value using XMLDocument? Thank you for your answer.
<italic>Work hard, Work effectively.
|
|
|
|
|
What do you mean you return 12?
/\ |_ E X E GG
|
|
|
|
|
I forgot. Sorry. Here:
If I get a return from a XML web service, like this : <value>12</value>. How do I retrieve the value using XMLDocument? Thank you for your answer.
<hr><italic><small>Work hard, Work effectively. </small></italic>
|
|
|
|
|
assuming you already have this xml loaded into a XmlDocument (doc) instance.
Can you show me your whole xml file hierarchy? I need it to show you a better example.... Here's what I can show you now...
XmlNode node=doc.SelectSingleNode(xpath...);
string alexEggRules=node.InnerText;
and alexEggRules will have "12" in it...
/\ |_ E X E GG
|
|
|
|
|
<NewDataSet>
<Table>
<Country>Indonesia</Country>
<City>Ujung Pandang / Hasanuddin</City>
</Table>
</NewDataSet>
Thanks Alex.
|
|
|
|
|
ok. Well now I don't know what node you want. So well just say we want the value of the Country node. Also, I'm assuming that the xml will only contain one instance of the node, so I'm using SelectSingleNode, if there are more then one instance, you should use SelectNodes.
So we have our XmlDocument doc, which has the below xml in it, and we are going to get the value of Country.
XmlNode node=doc.SelectSingleNode("//NewDataSet/table/Country");
string country=node.InnerText;
and that's it. If you have more then one instance of table or NewDataSet, we need to use a XmlNodeList instead of an XmlNode and SelectNodes instead of SelectSingleNode. Once we have the XmlNodeList, we can iterate through it with a foreach.
XmlNodeList nodes=doc.SelectNodes("//NewDataSet/table/Country");
string [] country=new string[nodes.Count];
int i=-1;
foreach(XmlNode node in nodes)
{
country [i++] =node.InnerText;
}
Any questions?
<NewDataSet>
<table>
<Country>Indonesia</Country>
<City>Ujung Pandang / Hasanuddin</City>
</table>
</NewDataSet>
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote:
Any questions?
Nope. I got it very clear. Thank you very much.
<italic>Work hard, Work effectively.
|
|
|
|
|
I have awindows application in C#.net. I made a patient Object. It has some variables like firstName. I declared this variable as private and made propeety FirstName. Is it good to put validation in the set method of property. If yes then suppose a FirstName on the form is empty and we click on add button to save the record. then a new object is created for patient but it will give a message of empty firstname when we assign the textbox value of the form to it. But after giving message i want to stop any further processing and set the focus to firstname textbox . How can i do that. Presently it continues with the other variables and create a object in the end.
Thanks
Monica
|
|
|
|
|
monica2k wrote:
Is it good to put validation in the set method of property.
No. Validation should be a completely separate method. The property should simply return the field value or set it.
To do validation, take a look at the Validated and Validating events that are part of every control. These explain how the validation works with response to the control losing focus--meaning, a value has been entered and the user tabs off the control or selects a different control.
Of course, it's a flawed system. Selecting a menu item does not cause a control to lose focus.
Marc
My website
Latest Articles:
Undo/Redo Buffer
Memento Design Pattern
|
|
|
|
|
This is probably a newbie question, but I can't find any info on how this works.
I'm creating a VS project file for ICSharpCode's TextEditor, and it wants to read some data using GetManifestResourceStream:
assembly.GetManifestResourceStream("SyntaxModes.xml");
While I have the individual files, I haven't a clue how to actually create the resource file. I tried Lutz Roeder's resourcer, so now I have a resx file with all these xml files in it, but that didn't work.
Any pointers or links to sites that explain how to do this?
Thanks!
Marc
My website
Latest Articles:
Undo/Redo Buffer
Memento Design Pattern
|
|
|
|
|
You just have to set your SyntaxModes.xml's build action property to Embedded Resource, that's all.
And don't forget the namespace when accessing the resource.
Regards,
mav
|
|
|
|
|
|
Ok, I seem to be having a very bad day today!
Inside a function where I am assembling several variables to use in queries -
This is where I am hanging up,I have several strings like this "nowhere_here" that I need to parse out what is after "_" so that I now have a tempstr = "here".
Then I need to pass this to a func that will do a switch on the string and return a valid string.
Question 1. What is my syntax for the split??
Question 2. How should I do the func? public string public void? then what do I say in the main string to get the value that is the result of the func??
Thanks all!
D @ Premier
You are only as good as your last project.
|
|
|
|
|
DEWright_CA wrote:
Question 1. What is my syntax for the split??
string foo = "nowhere_here";
string newstring = foo.Substring(foo.IndexOf('_')+1);
DEWright_CA wrote:
Question 2. How should I do the func? public string public void? then what do I say in the main string to get the value that is the result of the func??
public/private/protected (static) string Foo(string bla) { ... }
Depends on where you want the function to be accesible from and whether you want it to be static or not.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I will be passing foo to a "func(txtStr)" and need to get back a string called validFoo.
Thanks for the great reply, I forgot that I could do a IndexOf inside a substring!
|
|
|
|
|
Even worse, I also need to get the part of foo before '_', trying to do this;
string [] parts = foo.Split(new char[]{'_'});<br />
string theTable = homeTbl + parts[1];
But keep getting a "Index was outside the bounds of the array"
You are only as good as your last project.
|
|
|
|