|
In your example you try to read after the written data (MemoryStream position != 0).
You have to reset the read position of the memory stream.
MemoryStream ms = new MemoryStream();
ds.WriteXml(ms);
ms.Seek(0, SeekOrigin.Begin);
ds.ReadXml(ms);
|
|
|
|
|
Aah yes, silly me, I forgot about the pointer.
Thank you!
|
|
|
|
|
Keefb is coirrect, you have to rewind the stream, using:
if (ms.CanSeek)
{
ms.Seeek(0,SeekOrigin.Begin);
}
But be aware it may not work! You may well need ms.FlushFinalBlock() to ensure that last bit of data is written.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
If you look at the value of ms.Position after you have wrote in it, you'll see that has the same value of ms.Length . That is because you have just written into the stream and the stream cursor is located at the end.
Due to that, if you try to read the stream content, the reader doesn't found anything to read, giving the "Root Element is missing" exception.
Call ms.Seek(0, SeekOrigin.Begin) (or set ms.Position = 0 ) to move the cursor back to the beginning of the stream after writing and before reading.
|
|
|
|
|
if all else fails, maybe try and set ms.Position=0;
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
This is regarding late binding on a custom DLL in C#.
Basically, I have a self-written DLL which I wrapped using TLBIMP.exe.
Now I am trying to map the DLL's events to that of my own form. The events inside the DLL originate from a class.
I have tried almost every solution I was able to Google and nothing works.
Please do not reply to my thread if you have just Googled for a solution yourself, I need to hear from someone who has done this before. I've tried Google.
Details:
O.k, I'm going to use simpler names than that of my actual code.
My DLL file is called wrapper_MyDLL.dll and I load it as follows:
System.Reflection.Assembly _assembly = Assembly.LoadFile("wrapper_MyDLL.dll");
I save the Type as follows:
System.Type _classType = _assembly.GetType("wrapper_MyDLL.MyModuleClass");
I save the Class Object as follows:
object _classObject = Activator.CreateInstance(_classType);
Now from this point on I have tried so many different pieces of code to get the event that I'd rather not try to provide my attempted solution.
However, I can give some detail about my DLL.
If I loop through _assembly.getTypes() I get (among other) the following two classes:
* wrapper_MyDLL.MyModuleClass<br />
* wrapper_MyDLL.__MyModule_ReceivedMessageEventHandler
Inside the class wrapper_MyDLL.MyModuleClass, the DLL exposes the following (among other):
Methods:
* add_ReceivedMessage<br />
* remove_ReceivedMessage
Event(s):
* ReceivedMessage
Inside the class wrapper_MyDLL.__MyModule_ReceivedMessageEventHandler, the DLL exposes the following (among other):
Methods:
* get_Method<br />
* get_Target
Properties:
* Method<br />
* Target<br />
Now, how do I go about having that event (ReceivedMessage) fire in a method in my C# project?
If you think you can help and need any more info, let me know.
Kind Regards
modified on Tuesday, October 20, 2009 9:14 AM
|
|
|
|
|
I got absolutely no idea on how you'd hook up that event, and you don't want me to Google. If it were an interview-question, I'd suggest sending a message to the mainform and handle it in the WndProc. Kinda like InterOpping to yourself
I are Troll
|
|
|
|
|
See, that's why I asked you not to reply if you don't actually know what my problem is.
You marked your response as an ANSWER while in fact I still have no answer at all.
What am I supposed to do now? Repost my post as a new to regain my post's "unanswered" status?
Sorry for coming across as hostile, I appreciate the suggestion you made.
The thing is, here are many posters who, for some reason, try to answer just about every problem whether they know the answer or not, simply to up their number of posts. And once a post has been answered it has much less of a chance of being seen by someone who could actually help.
Understand my reasoning?
|
|
|
|
|
Hi!
I will use the DateTimePicker with working BackColor in a project of me, but in the project I need to see witch part of the customformated DateTimePicker is selected. A normal DateTimePicker from MS has this funktion but on that i can't change the BackColor.
Thanks,
blind1985
|
|
|
|
|
i have tow datagridview i wanna delete from the first grid and add the deleted row to other grid ...
thx all
|
|
|
|
|
And what kind of problems with performing this are you having?
|
|
|
|
|
i dont have problem
but i wanna take the professional solution
using datagrid classes
thx for reply
|
|
|
|
|
what's the problem ?
DataGridViewRow firstRow = grid1.Rows[0];
grid1.Rows.Remove(firstRow);
grid2.Rows.Add(firstRow);
that's all...
|
|
|
|
|
|
can i do that by doubleclik on row???
|
|
|
|
|
Ya you can!!
just write this code in the datagridviewcelldoubleclick event.
your job is done dude!!
|
|
|
|
|
I created a site collection in a Web Application using the following code snippet in a Console Application:
============================================================================
SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://devportal.domain.local"));
webApp.Sites.Add(
"/", // site URL
"testsite", // site title
"Test Site Description", // site description
1033, // site LCID that represents the language, e.g. 1033 = en-US
"STS#0", // site template, e.g. STS#0 = Team Site
@"localdomain\my_alias", // site owner login
"Test Owner", // site owner name
"abc@def.com"); // email
Console.WriteLine("Site Created");
Console.ReadLine();
============================================================================
However, I am not able to view the same? How should I view it?
modified on Tuesday, October 20, 2009 8:33 AM
|
|
|
|
|
mgr_2k7 wrote: How should I view it?
As a total mess! What is this supposed to be about and what is its relevance to the C# forum?
|
|
|
|
|
mgr_2k7 wrote: How should I view it?
Poorly.
This code is a mess and made less readable by the fact you haven't enclosed it in pre tags.
When I did decipher the code, SPWebApplication is a Sharepoint class, so you've posted to the wrong forum.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Hello Friends,
I am facing problem to merger 2 or multipule Multidimensional Array into Single Multidimensional Array in C#.
Please help me how can I do this.
|
|
|
|
|
Hi Friend!
The more clarity you give to your question will get the answer fast.
Please try to give the code and errors so that some one can help you with
clear idea
thanks
|
|
|
|
|
basantakumar wrote: I am facing problem
Well you need to describe it in better detail than this. Show us what code you are using, what you expect to happen, and what is (or is not) happening, that causes you a problem.
|
|
|
|
|
Thanks a lot. I have done that.
|
|
|
|
|
I have a similar requirement, could you please help me how you did this?
|
|
|
|
|
Hi
i'm looking for which how to visual studio generate code when u are working on design mode. for example, suppose u have a web project with visual studio, when u add gridView to yout web page, it generate aspx code in .aspx file on the specific line of page, when u change some default properties of gridView, it add code to .aspx, and when u delete gridView, it delete gridView code that wrote to aspx file. i'm looking for a best way to accomplish this (user design form and my application generate aspx code for it).
can anybody help me ?
thanks
|
|
|
|