|
So far I needed to put a MemoryStream's content to a byte array two times, but in each case MemoryStream.Read() gave back corrupt data.
In the first case I saved an image into a stream then used Read() to put it into a byte[]. When I used Write() to get back a stream from the byte[], the stream was corrupt and I couldn't create an Image from the stream.
The second time I used Read() I tried to put a serialized object into a byte[] and return it to the client with remoting as a return parameter. This time when I used Write() to get back a stream I, BinaryFormatter.Deserialize() threw an error about how the binary stream's header was corrupt (or something like that).
In both cases using MemoryStream.ToArray() instead of MemoryStream.Write() worked as expected, creating a correct byte[].
Both methods use InternalBlockCopy but I'm not familiar with that external function.
I'm just curious if you met the same problem and if you know what causes it.
|
|
|
|
|
After writing, you have to reset the file position before reading the data.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Guffa wrote: After writing, you have to reset the file position before reading the data.
Before deserializing if I don't reset the position I get another error: "End of Stream encountered before parsing was completed.". If I reset the position, then the error is: "Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization."
|
|
|
|
|
You probably made the same mistake earlier
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
I just wanted to show that an error caused by not resetting the position is different from the error caused by using MemoryStream.Read() to fill the byte array. I knew I had to reset the position even before I made my first post. The situation was the same when I used Image.Save().
|
|
|
|
|
Ok, that's the only problem that I can think of. If you want anything more specific than a guess, you have to show the specific code that you are using.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi,
How can i create custom control like fontdialog, colordialog. I mean I dont want to inherite from them, i just want to drag them in form and it will come at the bottom area and i can use them , e.g : ColorDialog Control, when we drag into form its come to bottom area of form and we can use the property. I want to create such type control .
Please Give me some idea !!!
Thanks in Advance
|
|
|
|
|
Inherit from a Component... This will make your object appear in the bottom area in stead of on your form...
|
|
|
|
|
Thanks a lot. 5 from me.
Thanks
|
|
|
|
|
Hi, Can you help me once more...
while i am changing the icon of control using
[System.Drawing.ToolboxBitmap("vdir.ico")]
toolbox icon get changed , while draggin the icon on form , its appering a as defult icon in the bottom,
please help me
Thanks in Advance !!!
|
|
|
|
|
Hey,
does somebody know, if it is possible to host Powershell within c# and authenticate as administrator. Hosting Powershell is not the problem, but the thing with the authentication
Situation:
I need to write an application for Managing Exchange (ExchangeSnap in works fine) an DNS. To get this done I decided to use powershell instead of (psexec.... etc.) My Problem now is that if the user is not an administrator he should enter his admin credentials so that he can use f.ex. dnscmd over powershell.
I hope somebody can help, because i stuck in this .....
Thanks a lot
|
|
|
|
|
Hi,
I have developed a application in which the user will be given the freedom to drag and drop labels and pictureboxes so the whole process is done on a canvas(form) now before starting the actual work i want user to decide the dimensions of the form so i placed two text boxes and a button so whenever the user enters the dimensions and click the button the form of same size is displayed my problem is that this functionality is working with the pixel size i want the user to enter the values in inches if anyone knows how to do this please let me know
regards
sindhu tiwari
its me sid
|
|
|
|
|
Hi,
I have a question. I believe that back in the day API's where used by C++ ect. I also believe that API's are unmanaged code and C# uses managed code by way of Assemblies.
Can someone please tell me if it's possible to use API's in a C# app or point me to a good website where I can read up on it?
ThankS!
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
You can use APIs in C# no problem. Suppose that you want to get the hotspot information out of an icon using the API, you would do this:
public class MySampleApiWrapper
{
[StructLayout(LayoutKind.Sequential)]
public struct ICONINFO
{
public bool bIcon;
public int xHotspot;
public int yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColour;
}
[DllImport("user32.dll", EntryPoint = "GetIconInfo")]
public static extern bool GetIconInfo(IntPtr hIcon, out ICONINFO piconinfo);
}. To get this information, you would use
ICONINFO iconInfo = null;
if (GetIconInfo(icon.Handle, out iconInfo))
{
Trace.WriteLine(iconInfo.xHotspot);
} For details on some of the API calls and there signatures, you can use this[^] site.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All
I have a website running on MS Digital Dashboard Dotnet 1.1 In one pannel I open up a section where you can cahnge an attribute for a customer. There are 2 buttons that either submit the change or deletes the attribute.
When I click on the update button, it doesnt stop at the breakpoint I have set, it looks as though something is happening as the IE status bar starts working, but after a short time i get "Page cannot be displayed.
I have run reg_iis.exe -c, I have created a new button, I have added an event to a checkbox and non of these things make any difference, I still get "Page cannot be displayed".
If anyone can help, I would really appreciate it.
Thanks
Angela
|
|
|
|
|
I would like to create a messagebox with a details button,
So for example:
ERROR!
Could not connect to database
|OK| |Details|
And then when you click details that it shows the expection message,
Is this possible? Or would i have to create a new form to mimic a message box??
|
|
|
|
|
If you are using Vista, then you can use a TaskDialog. If this is targetting pre-Vista, then you will need to roll your own form. Sorry.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
A messagebox is just a form. Yes, you need to create a new form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
I have a PrintPreviewControl on my form, where print preview should be displayed.The problem is, that even when I set the Document Property of this control to a new created document, it doesn't raise any Print event. It always displays "Document does not contain any pages" text.
if (this.DocumentPreview == null)
{
this.DocumentPreview = new PrintDocument();
this.DocumentPreview.PrintPage += new PrintPageEventHandler(DocumentPreview_PrintPage);
this.DocumentPreview.BeginPrint += new PrintEventHandler(DocumentPreview_BeginPrint);
this.DocumentPreview.EndPrint += new PrintEventHandler(DocumentPreview_EndPrint);
this.DocumentPreview.DocumentName = "Generating document";
}
this.printPreviewControl.Document = null;
this.printPreviewControl.Document = this.DocumentPreview;
Do you have any idea why ?
zilo
|
|
|
|
|
I've solved that,
In case that any1 had same problem, PrintPreviewControl.InvalidatePreview() is the solution.
zilo
|
|
|
|
|
Hi,
I am sid a electronics engineer presently i am working in a company as a software developer n developing windows based applications i want to know abt the mobile applications as this forum is filled with the expertise persons i know i will be getting the most benificial suggestions ..plz any sites ....any books ...
regards
sindhu tiwari
its me sid
|
|
|
|
|
You are going to want to download the .NET Compact Framework, and the Documentation for it. If you are already a C# .NET developer, you will find that it isn't different at all. Save for that the version of .NET is called Compact. Limited functionality of the framework to save space on a small footprint device.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
ya bcoz we can learn in jungle also but a person like u cant learn cant earn n cant be happy anytime anyways thank u now this is indian style dare to do this things again
its me sid
|
|
|
|
|
What did you just say? Not a single bit of that made sense.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
His last 2 lines are "signature", not a reply to your post.
|
|
|
|