|
|
|
I have a web service that will upload/retrieve images from a MySQL database. I am passing it an array of objects to signify multiple images (although I am only using one). Anyway when I get the binary array and try to execute oCmd.ExecuteNonQuery(); I get the following error:
', hexadecimal value 0x10, is an invalid character. Line 1, position 449.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: '', hexadecimal value 0x10, is an invalid character. Line 1, position 449.
The code I use is as following:
OdbcCommand oCmd = null;<br />
foreach(String name in names) <br />
{<br />
byte[] singleton = data[names.IndexOf(name)] as byte[];<br />
oCmd = new OdbcCommand("INSERT INTO images (name,data,length,user) VALUES (?name,?data,?size,?user)",oCon);<br />
<br />
OdbcParameter p0 = new OdbcParameter("?name",OdbcType.VarChar,100);<br />
p0.Value = name;<br />
oCmd.Parameters.Add(p0);<br />
<br />
OdbcParameter p1 = new OdbcParameter("?data",OdbcType.Binary);<br />
p1.Value = singleton;<br />
<br />
OdbcParameter p2 = new OdbcParameter("?size",OdbcType.Int,20);<br />
p2.Value = singleton.Length;<br />
oCmd.Parameters.Add(p2);<br />
<br />
OdbcParameter p3 = new OdbcParameter("?user",OdbcType.VarChar,100);<br />
p3.Value = username;<br />
oCmd.Parameters.Add(p3);<br />
<br />
oCmd.ExecuteNonQuery();<br />
}
I am thinking maybe it's an issue with Encoding? Unfortunately I was never good at dealing with Encoding. Can anyone help?
|
|
|
|
|
If your data is XML, then you need to put your image in a CDATA section, or you'll get this sort of an error.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How would I go about doing that if I am using SOAP to transport the data to and from the web service? Also I read that CDATA only makes the problem less likely (IE: if the string is terminated by ])> it will cause the section to end) and I figure that if I'm going to be using this just for images the liklihood of that would be pretty high. Any suggestions? I tried using Base64 encoding, but that gives the same error.
|
|
|
|
|
methodincharge wrote:
Also I read that CDATA only makes the problem less likely (IE: if the string is terminated by ])> it will cause the section to end)
Yes, if you manage that three character set in your image, then you'd have a problem. The changes of that are 255*255*255 to 1, as far as I can see.
methodincharge wrote:
I figure that if I'm going to be using this just for images the liklihood of that would be pretty high
Why ?
methodincharge wrote:
How would I go about doing that if I am using SOAP to transport the data to and from the web service?
Put the CDATA tags around the image data before passing it to the SOAP layer, and remove them at the other end.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hey
I'm trying to serialize a listbox, but I keep on getting an error that it is not serializable.
anyone has any idea on how should I be doing that?
|
|
|
|
|
using System.Runtime.Serialization;
[Serializable] public class ListItem : ISerializable
{
}
|
|
|
|
|
thanks, I'll try that
|
|
|
|
|
is there a way to reverse a string....like you could in MFC?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I don't know if it's the best way, but...
string sTest = "abcdefg";
char[] sTestRev = sTest.ToCharArray ();
Array.Reverse (sTestRev);
sTest = new string (sTestRev);
|
|
|
|
|
I am having a hard time finding how to add a collection to a custom property.
i have a datasouce property ( datatable ) and i would like another property that allow me to choose the datacolumns i would like to use(from the datasouce above).
i have no problem with the datasource property but the datacolumns i do not know how to add. Can any one help?
thank you
drey
|
|
|
|
|
anyone have any examples of creating a custom form similar to those used in applications like MS Photo Editor, Adobe Illustrator, Etc?
|
|
|
|
|
Hi, I'm trying to update an app.config file for an application. After I update the config file how do I tell the application to "refresh" the settings it read from the config originally?
example:
string val = ConfigurationSettings.AppSettings["companyName"];
// val = "My Co"
use my own routine to write the setting:
SetValue("companyName", "YourCo");
string val2 = ConfigurationSettings.AppSettings["companyName"];
// val2 = "My Co", but I want it to be "YourCo"
It's only after I close the application and restart it that I pick up the "YourCo" value.
Thanks for any suggestions,
Trevor B
|
|
|
|
|
You can make it by the xmlreader class in the i/o namespace.
|
|
|
|
|
You could add a Settings.settings file to your application.
When you edit this file in VS you have to change the Scope to User.
After that:
DateTime _date = DateTime.Today;
if (_date.Year > Properties.Settings.Default.MyDateOfSomething.Year)
{
Properties.Settings.Default.MyDateOfSomething = _date;
}
Properties.Settings.Default.Save();
Properties.Settings.Default.Upgrade();
|
|
|
|
|
How do I trap for running during development and when the system is complete.
I would like to open config files in the startup directory of the exe when the system is complete.
But during development the default directory is the bin dir.
I need to test for development and walk up ..\..\ or if not development assume the current dir is were the exe is.
Thanks.
|
|
|
|
|
During development,you can put it it same directory as the exe,and during the runtime it will be in the same directory ,and you can have that directory programtically by the user of Application.Startuppath property.
|
|
|
|
|
You can get the full path of the exe from Application.ExetutablePath.
eg.:
<br />
System.IO.FileInfo fi=new System.IO.FileInfo(Application.ExecutablePath);<br />
<br />
string exedir=fi.DirectoryName;<br />
|
|
|
|
|
From my web service client I would like to change the default way some xml is being deserialized. WSDL.exe creates a client that deserializes this xml as an array.
The xml node in the message looks like this:
<IDs>
<id>xxx</id>
<id>yyy</id>
</IDs>
I would like to have the entire xml node returned as a string or preferably as an XmlNode object.
I understand I need to change the return type of the GetIDs call but I don’t know what I should change the attributes on the method to stop this from being converted into an array. Obviously I need to remove the XmlArrayAttribute but what do I replace it with???? There does not seem to be an "XmlNodeAttribute" to deserialize the xml ID node into an XmlNode object.
Thanks for any thoughts.
Here is the method that I do not know how to edit to get the desired results:
<br />
[System.Web.Services.Protocols . . . <br />
[return: System.Xml.Serialization.XmlArrayAttribute("IDs", IsNullable=true)]<br />
[return: System.Xml.Serialization.XmlArrayItemAttribute("id", IsNullable=false)]<br />
public string[] GetIDs() <br />
{<br />
object[] results = this.Invoke("GetIDs", new object[0]);<br />
return ((string[])(results[0]));<br />
}
This is an example of the raw soap message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope>
<soap:Body>
<GetIDsResponse xmlns="http://www.tempuri.com">
<IDs>
<id>1111</id>
<id>2222</id>
<id>3333</id>
<id>4444</id>
<id>5555</id>
</IDs>
</GetIDsResponse>
</soap:Body>
</soap:Envelope>
|
|
|
|
|
I'm displaying a TreeView of an active directory domain. I want to right-click on a Node and display a context menu which has a submenu which is built depending on the type of object clicked on.
I've created a context menu but when right-clicking on an object, this code, running in the Popup event of the context menu item which displays the sub-menu:
MenuItem directoryObjectClickedOn = (MenuItem)sender;<br />
ContextMenu cm = directoryObjectClickedOn.GetContextMenu();<br />
TreeView ad = (TreeView)cm.SourceControl;<br />
DirectoryEntry aDObject = (DirectoryEntry)ad.SelectedNode.Tag;<br />
MessageBox.Show(aDObject.Name);
always gives me the previous object, not the current one.
Any idea how to get the current object?
|
|
|
|
|
In the MouseDown/Up event, get the x and y coordinates of the cursor. From this you can determine which node the mouse is on by using the GetNodeAt() method. If you want to know if a mouse has selected the tree view item label or its icon.
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thanks very much. That sorted it out for me and I'm generating a context-specific menu.
|
|
|
|
|
Hello!
In C++ one could indent listview items very easily: lvi.iIndent = 1. Now, how can we do the same in C#?
I've read something about a ListViewItem.IndentCount and ListViewItem.NumIndents properties, but my compiler doesn't know these members... All other things work quite nicely (lvi.ImageIndex, lvi.SubItems.etc.).
Thanks in advance and best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I've been battling this for a long time, and i managed to get it working with the Icon class, but due to recent changes in a program I'm working on, I now have to keep all my icons as Image class members. This gives me the black border around alpha transparent pixels in my icons. This is the code i'm using:
For the API:
<br />
private static uint SHGFI_ICON = 0x100;
private static uint SHGFI_LARGEICON = 0x0;
private static uint SHGFI_SMALLICON = 0x1;
[DllImport("Shell32.dll")] <br />
<br />
private static extern int SHGetFileInfo( string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, int cbfileInfo, uint uFlags); <br />
<br />
private struct SHFILEINFO <br />
{ <br />
public IntPtr hIcon; <br />
public int iIcon; <br />
public int dwAttributes; <br />
public string szDisplayName; <br />
public string szTypeName; <br />
} <br />
<br />
public enum FileIconSize <br />
{<br />
Small,
Large
}<br />
<br />
public static Image GetFileIcon(string fullpath, FileIconSize size) <br />
{<br />
SHFILEINFO info = new SHFILEINFO();<br />
<br />
uint flags = SHGFI_ICON;<br />
if (size == FileIconSize.Small) <br />
{<br />
flags |= SHGFI_SMALLICON;<br />
}<br />
<br />
int retval = SHGetFileInfo(fullpath, 0, ref info, System.Runtime.InteropServices.Marshal.SizeOf(info), flags);<br />
if (retval == 0) <br />
{<br />
return null;
}<br />
<br />
System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(info.hIcon); <br />
<br />
System.Windows.Forms.ImageList imgList = new ImageList();<br />
imgList.ColorDepth = ColorDepth.Depth32Bit;<br />
imgList.ImageSize = icon.Size;<br />
imgList.Images.Add(icon);<br />
return imgList.Images[0];<br />
} <br />
Actual working code on a Windows Form:
<br />
Graphics g = Graphics.FromHwnd(this.Handle);<br />
g.FillRectangle(System.Drawing.SystemBrushes.ControlDark,20,50,32,32);<br />
Image ico;<br />
ico = API.GetIcon(ofd1.FileName, API.FileIconSize.Small);<br />
<br />
<br />
g.DrawImage(ico, 20,50);<br />
can anyone tell me what i'm doing wrong? i thought i had taken care of all the little possible ways to screw it up, such as converting it to a bitmap...
|
|
|
|