|
Thank you, I'll study it and re-open the question if it wasn't enough
|
|
|
|
|
Hi all,
I've got a struct which I'm controlling the Marshalling of using
[StructLayout( LayoutKind.Explicit, Size = 32)]
However I've found that while Marshalling it to a byte[] on a desktop XP machine produces the expected 32 bytes, on an ARM-based WinCE machine it only produces 28 bytes.
How can I get consistent Marshalled byte sizes across platforms, and why doesn't the WinCE .NET CF Marshal it the way I've specified?
TIA
|
|
|
|
|
MSDN on StructLayout.Size is a bit bizarre. It holds a remark "This field must be equal or greater than the total size, in bytes, of the members of the class or structure. This field is primarily for compiler writers who want to extend the memory occupied by a structure for direct, unmanaged access. For example, you can use this field when working with unions that are not represented in metadata directly."
Which one can read as: the actual size should not exceed the specified size value.
Therefore I recommend that you consider adding dummy members to your struct to obtain the exact size you want.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
It's still a bit rubbish that they give you the ability to specify how the conversion is handled, but then ignore it if they feel like. Oh well, it's working fine with padding.
|
|
|
|
|
There is a Listview in Form1, named "listview1", I try to add a item from Form2, it doesn't work. But no error prompts were given.I have changed the type to "public" for listview1.
In Form2, the code is:
ListViewItem li = new ListViewItem();
li.SubItems.Clear();
li = new ListViewItem(new string[] {"Richard","28","Male"});
Form1 form1 = new Form1();
form1.listView1.Items.Add(li);
It passed successfully without errors, but the listview1 did nothing. where does the problem lie in? Thanks.
|
|
|
|
|
imbiz wrote: Form1 form1 = new Form1();
There is your problem. Do you know what new means? It means: create another instance of Form1, i.e. a second Form1 looking very much like the first, but not visible as you did not call Show() on it. You do not want another Form1, you want the original one. So pass a reference, do not use new here.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
But how to use listview1 in Form1 directly? It seems we can't use "Form1.listview1.Items..." in Form2.
modified on Tuesday, June 8, 2010 8:52 AM
|
|
|
|
|
One method to look at would be to use an event in Form2 and subscribe to it from Form1. This event would be used to notify Form1 that there was a new value that needs adding to the listview.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thank you , but I'm still puzzled.
|
|
|
|
|
Why? Have a look in this[^] article for some help.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I found another way.
I simply changed the type of listview1 in Form1 to "Public Static", now I can update the data in Form2.
Of course this is against the principle of "OO(Object Oriented)".
I will read that article you give me, maybe use of delegate is the best choice,thank you.
|
|
|
|
|
Hi,
I am a newbie to .NET.
I need to design an IP address control.
I can design a control on my own with edit boxes.
But before that i want to confirm whether we have any default IP address control in VS2008. I could not find it in the Tool box.
Do we have any default IP address control in VS2008 or 2010?
Thanks.
Selva
|
|
|
|
|
SelvaKr wrote: Do we have any default IP address control in VS2008 or 2010?
No. There's not one supplied by default.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
|
|
Hello Everyone,
I have been using Crystal Report for at least 7 years, but I never got this below exception before, when I wanted to set report data-source :
Parameter Count Mismatch.
Note that, I converted my project from VS 2008 to 2010. I didn't have any problem like this in VS 2008 before everything was working fine. After conversion and change appropriate crystal report references, It doesn't work anymore.
Below is my code :
private void PrintInvoice(int accountId)
{
List<vwSalesModel> invoiceMdl = GetInvoiceInformationByAccountId(accountId);
if (invoiceMdl == null)
return;
using (frmReportViewer frmReport = new frmReportViewer())
{
rptInvoice invoiceReport = new rptInvoice();
frmReport.crystalReportViewer.ReportSource = invoiceReport;
invoiceReport.SetDataSource(invoiceMdl);
frmReport.ShowDialog();
}
}
Any Advice will be helpful.
Regards
SABER.
http://codeprojects.wordpress.com
|
|
|
|
|
Hi to all,
I write below code to create backup
but it doesn't work
ServerConnection connection = new ServerConnection(".");
Server srv = new Server(connection);
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
Backup bkpDatabase = new Backup();
bkpDatabase.Action = BackupActionType.Database;
bkpDatabase.Database = txtDBName.Text;
BackupDeviceItem bkpDevice = new BackupDeviceItem(sfd.FileName, DeviceType.File);
bkpDatabase.Devices.Add(bkpDevice);
bkpDatabase.SqlBackup(srv);
}
|
|
|
|
|
I think you need to clarify with some more detail... your given code snippets is not enough to figure out what is wrong.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
|
Better, but still needs some more.
What is the error message and which line of code generates it.
If you have no errors then you need to look into the event logs on the server to see if there are any messages from SQL Server.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
"One notable quirk occurs when you use the standard pass-by-value mechanism. In this
e, pass-by-value doesn’t create a copy of the object, but a copy of the reference. This refer-
e still points to the same in-memory object. This means that if you pass a Product object t
ethod, for example, the method will be able to alter your Product object, regardless of
ther you use pass-by-value or pass-by-reference."
Beginning ASP.NET 3.5 in C# 2008 (ISBN-13 (pbk): 978-1-59059-891-7) P.69
Can anyone provide a code snippet to demonstrate the above? If the above were a valid statement, wouldn't this be a bug in the .NET 3.5 framework?
Jon
|
|
|
|
|
It's true for strings and primitives. What are they passing?
|
|
|
|