|
treuveni wrote: What i'm doing wrong?
...
dt.Columns.Add(pi.Name, pi.PropertyType);
Guess you wanted to use propType instead of pi.PropertyType ?
|
|
|
|
|
Hi,
I am getting the same error. Did you figure it out? If so, can you please let me know.
Thanks in advance.
Ken
|
|
|
|
|
How can I check SD card is broken?
|
|
|
|
|
Stick it into the SD card slot. Can you read it?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
|
Hello again everyone
I have a set of bytes which needs to be bit masked, and i want only the result of the bitmask to be displayed on form.
EG
Byte value 3A 0011 1010
Bit Mask 30 0011 0000
AND 0011 0000
result in byte is 30, but i want only the '3' to be displayed. How do i determine how many bits to shift just by looking at the bit mask value?
|
|
|
|
|
Do you mean you only want the first Hex digit? If so, >> 4
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
yep shifting 4 places would work for that example but im working on a bunch of values and the bitmask is a myriad of values (01,02,04,08,10,20,40,80,C0,FE,FB etc). My question is how do u determine how many bits to shift just by looking at the bitmask value
|
|
|
|
|
Just shift right until the low order bit changes to 1, something like:
int count = 0;
while ((mask & 1) == 0)
{
mask = mask >> 1;
count++;
}
It's time for a new signature.
|
|
|
|
|
ah yes your method could work...gonna give it a shot now
|
|
|
|
|
yes ! that did the job! thanks!
|
|
|
|
|
My pleasure, good luck with the rest of your program.
BTW don't forget to vote the answer.
It's time for a new signature.
|
|
|
|
|
Hi all!
I have the following situation - three tables in the db :
- um_users (id, name)
- um_roles (id, description)
- um_user_roles (user_id, role_id)
I load into a data set two datatables : the "users" one, and another one build on the other two, like this :
_cmd = new OracleCommand("select * from um_users", _conn);
_odaUsers = new OracleDataAdapter();
_usersDataSet = new DataSet("um_users");
_odaUsers.SelectCommand = _cmd;
_odaUsers.Fill(_usersDataSet, "um_users");
_cmd = new OracleCommand("select u.user_id, r.role_id, r.role_name, r.descr " +
"from um_users u " +
"inner join um_user_roles ur on u.user_id = ur.user_id " +
"inner join um_roles r on ur.role_id = r.role_id ", _conn);
_odaUsers.SelectCommand = _cmd;
_odaUsers.Fill(_usersDataSet, "um_user_roles");
_usersDataSet.Relations.Add("users_uur", _usersDataSet.Tables[0].Columns["USER_ID"], _usersDataSet.Tables[1].Columns["user_id"]);
This snippet also adds a relation between the two.
I display them in a ultrawingrid from infragistics, and I'm able to edit them. Saving the modifications for the first table worked with no problem,but since the second one is more like a view, i have no ideea how should i proceed. should i build an insert command or how ?
Thanks!
|
|
|
|
|
I have a code block like this:
{
m_ReaderName = m_Reader.ReaderName;
m_Reader = new ProprietaryReader(ReaderName);
retVal = (int) Status.Success;
}
Q: how to cache the reader name using the input param??
Any help are deeply appreciated..
|
|
|
|
|
hello
How to convert any object to byte[] without marking it Serializable or DataContract?
Of course this would work but you'd need to mark myObj class Serializable (I'm lazy dont want handcode serializable for big classes sorry)
using (System.IO.MemoryStream returnStm = new System.IO.MemoryStream())
{
BinaryFormatter ftm = new BinaryFormatter();
ftm.Serialize(returnStm , myObj);
return returnStm .ToArray(); // this would return byte[]
}
Anyone who can tell me how I can commit such crime?
Thank you
|
|
|
|
|
Hi, I do this and it works for me.
public byte[] RawSerialize(object item, Type anyType)
{
int structSize = Marshal.SizeOf(item);
IntPtr ptr = Marshal.AllocHGlobal(structSize);
Marshal.StructureToPtr(item, ptr, true);
byte[] bff = new byte[structSize];
Marshal.Copy(ptr, bff, 0, structSize);
Marshal.FreeHGlobal(ptr);
return bff;
}
|
|
|
|
|
Many thanks I don't have time test it now but already feel my knowledge increase
|
|
|
|
|
Hello Gonzalo
Do you have the code for reverse process as well please please please?
|
|
|
|
|
public static object RawDeserialize(byte[] rawdatas, Type anytype)
{
int rawsize = Marshal.SizeOf(anytype);
if (rawsize != rawdatas.Length)
{ return null; }
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawdatas, 0, buffer, rawsize);
object retobj = Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
return retobj;
}
Here it is
|
|
|
|
|
Many thanks Master Cao! If I still can't get my WCF contract working I may just try serialize/de-serialize whole deal to byte[]
|
|
|
|
|
You welcome. Good luck with you project.
|
|
|
|
|
Oh bummer
<br />
{"Type 'XXXXX.MyAccount' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."}<br />
I suspect this is because MyAccount is actually a complex hierarchy containing a child collection...
<br />
class MyAccount<br />
{<br />
...<br />
public List<Invoicesgt; GroupList;<br />
}<br />
Eekkk... I was going to wire down an array of accounts (i.e. MyAccount[]) but now can't even wire down one single MyAccount... I desparation I tried this:
<br />
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())<br />
{<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
formatter.Serialize(stream, result);<br />
byte[] BinAcct = stream.ToArray());<br />
}<br />
But even then I ran into runtime exception, complaint was that class is not marked serializable (Although marked DataContract), looks like I got lucky with
<br />
DataContractSerializer dataContractSerializer = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
dataContractSerializer.WriteObject(memoryStream, Acct);<br />
btAccountSet = new byte[memoryStream.Length];<br />
Array.Copy(memoryStream.GetBuffer(), btAccountSet, btAccountSet.Length);<br />
}<br />
This finally get the job done (only serialization part, still stuck during deserialization).
<br />
1. Serialize side:<br />
DataContractSerializer serial = new DataContractSerializer(Acct.GetType());<br />
using (MemoryStream memoryStream = new MemoryStream())<br />
{<br />
serial.WriteObject(memoryStream, oAcct);<br />
btPayload = new byte[memoryStream.Length];<br />
Array.Copy(memoryStream.GetBuffer(), btPayload, btPayload.Length);<br />
}<br />
<br />
2. Deserialize side: <br />
byte[] raw = (byte[]) GetPayload();<br />
serial = new DataContractSerializer(typeof(MyAccount));<br />
using (MemoryStream memoryStream = new MemoryStream(raw))<br />
{<br />
memoryStream.Seek(0, SeekOrigin.Begin);<br />
oAcct = (MyAccount) serial.ReadObject(memoryStream);<br />
}<br />
So, all good sending a single object, but still need to attempt sending/serializing a list of MyAccount (with subclasses)
Thanks
modified on Saturday, August 21, 2010 1:46 AM
|
|
|
|
|
Were you able to fix it??
With the sample code you've posted I was not able to find the problem.
|
|
|
|
|
hey yes, many thanks, working now and I just dodged a tight deadline! (Code I posted actually works, forgot to remove "Bummer" as initially when I posted the reply I was still having problem)
Thanks very much!
|
|
|
|
|
I have mp2 video file withount sound (mv2) and wav file.
I want to create new file containning them both.
i search over the web code for multiplexing mv2 and wav and i found nothing.
if anyone framiliar with an open source code or have General direction for doing that
it sure can help a lot
Thanks in advance
|
|
|
|