|
Are the machines pingable by name AND IP? If they're pingable by IP, but not by name, then there ius a name resolution problem (DNS).
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi, i used ShockWaveFlash in my windows application.
i want to disable default ContextMenu for shockWaveFlash when my form runs.
how i can do it ?
thanks
|
|
|
|
|
What im trying to do is convert an image to a byte[], then write that byte array to an XML file as a string. I then want to be able to read back that file and convert the string to a btye array and then back to the image.
ASCIIEncoding encoding = new ASCIIEncoding();<br />
byte[] imageArray = ImageToByteConvert(style.Image);<br />
string imageString = encoding.GetString(imageArray);<br />
<br />
writer.WriteAttribute("Image", imageString);<br />
<br />
public byte[] ImageToByteConvert(Image imageIn)<br />
{<br />
MemoryStream ms = new MemoryStream();<br />
imageIn.Save(ms, ImageFormat.Gif);<br />
return ms.ToArray();<br />
}<br />
<br />
----<br />
<br />
attribute = domNode.Attributes["Image"];<br />
if (attribute != null)<br />
{<br />
byte[] imageByte = encoding.GetBytes(attribute.Value);<br />
retval.Image = ByteToImageConvert(imageByte);<br />
}<br />
<br />
public Image ByteToImageConvert(byte[] byteArrayIn)<br />
{<br />
MemoryStream ms = new MemoryStream(byteArrayIn);<br />
Image returnImage = Image.FromStream(ms);<br />
return returnImage;<br />
}
The problem is im getting an error saying:
03/01/2007 14:31:31 XmlModelSerializer.SerializeContent; Exception: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.<br />
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)<br />
at System.Drawing.Image.Save(Stream stream, ImageFormat format)<br />
at XmlModelSerializer.ImageToByteConvert(Image imageIn) in line 61<br />
at XmlModelSerializer.SerializeContent(IWriteContext context, SeverityNodeStyle style, IXmlWriter writer) in line 33
Line 61 is: imageIn.Save(ms, ImageFormat.Gif);
Any ideas?
Regards,
Gareth.
|
|
|
|
|
You would get the very informative message "A generic error occurred in GDI+" for
almost anything that can go wrong in Image.Save().
When saving to a file on disk it could be disk full, network disk disappeared,
file is locked, file is read-only, whatever. I dont know which of these have an
equivalent when saving to a memory stream.
It might also be a basic limitation of the GIF format (e.g. too many colors).
Are you sure you want GIF ?
And it could be a GDI bug (unknown to me).
Take your pick !
I would experiment with another format, say JPEG, at least to see if that works under
identical conditions...
Luc Pattyn
|
|
|
|
|
I tried changing the ImageFormat to .Jpeg, didnt change anything.
|
|
|
|
|
Hi Gareth,
I did some experiments with Image.Save() to memory stream, nothing went wrong.
Do you have your problem with every image ?
with the image(s) that goes wrong, does it fail on every attempt ?
is anything special about such image ? (size, number of colors, way it was created, ...) ?
what is its size ?
do you have a file containing such image, if so could you mail one failing image to me ?
furthermore, you could try to save GIF format to file instead of to memory stream,
then have a look at the file to see how large it gets (i.e. how far
the save operation succeeds), and (with hex viewer) possibly what is wrong.
If saving to file also fails, I could have a look to that file too...
Greetz
Luc Pattyn
|
|
|
|
|
Hi Luc,
It fails everytime on the same image and on different images. The image is only a 16x16 image, so is pritty small. How do i find out your email?, since i cant seem to view your profile.
Regards,
Gareth.
|
|
|
|
|
Ive kind of fixed the problem. Its being caused because i dont have write permissions i think, because if i specifiy the actual file location, eg: C:\ci.gif, i dont get the error. But if i try to get the image from my get/set method, the error appears.
The next problem i get through is when converting the image to bytes and visa versa.
public string ImageToByteConvert(Image imageIn)<br />
{<br />
MemoryStream ms = new MemoryStream();<br />
imageIn.Save(ms, ImageFormat.Gif);<br />
<br />
string imageString = Convert.ToBase64String(ms.ToArray());<br />
return imageString;<br />
}
I then write that string to the XML file which works fine. But if i try to read it back
byte[] imageByte = encoding.GetBytes(attribute.Value);<br />
retval.Image = ByteToImageConvert(imageByte);
I get an error saying:
05/01/2007 11:57:37 XmlModelSave.ReadGraph; Exception: System.ArgumentException: Parameter is not valid.<br />
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)<br />
at System.Drawing.Image.FromStream(Stream stream)
Which i believe to mean the bytes that i have just converted back from a string, arnt valid for the image im trying to create. But im unsure how to solve this.
Regards,
Gareth.
|
|
|
|
|
Hi Gareth,
I looked into your GIF file and did some experiments on it.
I was able to read the image, modify and save it, but something weird happened
to the background color.
Upon closer inspection of your image, it seems to have a 6-bit color scheme,
but a background color index of 255. This seems like an invalid combination.
Hence:
1) I wonder how you created such an image in the first place
2) I am surprised GDI+ does not throw an exception (one of those nice "a generic
error occured" messages)
Regards,
Luc Pattyn
|
|
|
|
|
I didnt create the image, it was already created before i started working on this current project.
|
|
|
|
|
|
which of events to use, and if none of them is actually one for this purpose I though of using KeyPress, but not sure how to make expresion that check if key is Enter (and then execute some method)???
|
|
|
|
|
Hello,
The KeyDown Event is what you are looking for.
YourTextBox.KeyDown += new KeyEventHandler(CheckKeys);
private void CheckKeys(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
}
}
All the best,
Martin
|
|
|
|
|
Here is my sample, but for KeyDown event:
<br />
private void textBox1_KeyDown(object sender, KeyEventArgs e)<br />
{<br />
switch (e.KeyCode)<br />
{<br />
case Keys.Enter:<br />
DoSomeStuff();<br />
e.SuppressKeyPress = true;<br />
return;<br />
case Keys.Escape:<br />
DoSomeStuff();<br />
e.SuppressKeyPress = true;<br />
e.Handled = true;<br />
return;<br />
case Keys.Space:<br />
DoSomeStuff();<br />
e.SuppressKeyPress = true;<br />
e.Handled = true;<br />
return;<br />
case Keys.B:<br />
DoSomeStuff();<br />
e.SuppressKeyPress = true;<br />
e.Handled = true;<br />
return;<br />
}<br />
}<br />
|
|
|
|
|
Looks like deleting youre question was not the best idea!
|
|
|
|
|
Not my fault ! Must be cp forum bug.
|
|
|
|
|
Was just a joke!
Maybe it has something todo, with the prevention of hacks, which chris maunder had to implement.
|
|
|
|
|
I think you need KeyDown or KeyUp.
add the event handler where you can do:
if(e.KeyCode == KeyCode.Enter){<br />
}
it should be something like this...
Hope this helps.
V.
If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)
|
|
|
|
|
Thanks I think it'll work, I wanted to do same thing but didn't know exact syntax...
|
|
|
|
|
Index 4 does not exist. The last line should read like:
string str = string.Format("{0:000}:{1:00}:{2:00}:{3:00}", d, h, m, s);
I.e. replace 3 by 2 and 4 by 3.
|
|
|
|
|
You were quite fast thank you I have solved problem in mean time
|
|
|
|
|
Hello friends;
i develop a .net ce 5.0 project and i need to set regional settings, how can i do it? Thanks for your helps
Best Regards
|
|
|
|
|
hi guys!
need some help.
i need to access files from my local network through an Asp.net Application on win2k3 IIS 6.
i tried to open the file through filestream but it gives an Access Denied error .
i tried this:
string ActualPath = "\\\\192.168.0.26\\c$\program files\abc\abc.exe"<br />
FileStream file = new FileStream(ActualPath, FileMode.Open, FileAccess.Read);
but it thows an unauthroized access exception..
but when i try to run this code on XP with iis 5 . it works fine .
cant figure it out wtz the problem.
abhinav
|
|
|
|
|
The cause is that IIS 6 is more secure (relatively) and won't allow access like this. You could play around with impersonation however in the end it is not a good idea to allow access to files or application through a webpage. There has been a great deal of effort to lock down and protect systems from hacks, viruses and miscredents.
only two letters away from being an asset
|
|
|
|
|
Hi
Regarding Treeviwe control in C# , I want to add child nodes to treenode(which is also a child node) after user clicks on + , that is after user expand that node.
now how to display a plus sign to that child node whose children will be added after expanding that node ?
in VB i used to add fake child so it was displaying a + sign and after expanding on it i used to add children, same should be happen here so please help me in doing that.
-sandeep
|
|
|
|