|
Glad to be of help
Funnily, my other post came because I thought in C not c#
Regards
David R
|
|
|
|
|
Had a think, and came up with this:
unsafe public void fred()
{
arAdrMsg[3].ulPGN = 1;
arAdrMsg[0].PGNspec = 0XFF;
fixed (ADRMSG* p = &arAdrMsg[0])
{
p->RxData[0] = (byte)0x00;
}
}
Again, it compiles but I don't know if it does what you want.
Regards
David R
|
|
|
|
|
Hi Bruce,
I don't know what the purpose of your question is, anyway fixing a member of a struct, while the struct could be anywhere doesn't make much sense: the offset of the member within the struct will be determined at compile-time, it will not change at run-time; and the location of the struct may or may not change, depending on where it lives: as a local variable, it sits on the stack and can't change; as a member of a reference type, it moves together with that reference type.
So what are you doing? is there any Win32 P/Invoke involved? or a fixed file format? or what?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:30 AM
|
|
|
|
|
Hi Luc,
Thanks for your response. We have no requirement to "fix" any storage location but when incorporating the array within the struct in order to identify there are 8 bytes within the array the compiler wanted it to be "fixed". We just need a circular queued array of strucures that can be acted upon within this class and also added to from an external class.
Cheers, Bruce
|
|
|
|
|
Hi Bruce,
if your struct is used in managed code only, and does not have to exactly match either a file structure or some unmanaged struct (as in Win32 API), then I suggest:
- you remove all the unsafe and fixed stuff;
- you use a regular array in that struct;
- optionally you add a constructor to your struct, which creates the array with 8 elements.
So it would look along these lines:
struct aha {
public int someInt;
public int[] theArray;
public aha() {
theArray=new int[8];
}
}
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:30 AM
|
|
|
|
|
I was looking for the original post to add more information but could not find it. Sorry for the duplication.
I have a VS NET 2003 application that runs only when the IDE is open under the IDE workplace.
If I copy the EXE file to another system (including its dependencies DLLs) it generates an error when I select (click a button) the option to connect to a DB , the error is “Object reference not set to an instance of an object”. The same error is also generated if I ran the application in the developers WS, however if I run the application with in the VS2003 IDE (Debug>Start without debugging), it works fine.
-I run dependency to check if missing files but application starts with no errors, it just won’t connect
-I check ODBC and he settings are the same between developers WS and target.
What is the debug option uses that makes it work?
Any ides where to start looking?
Any help is greatly appreciated
|
|
|
|
|
Did you try attaching the Debugger to the process when you run it from outside the IDE ?? (and see if it still crashes and why it crashes)
What is your connection string and code in button ?
|
|
|
|
|
Hi,
I have used the following code to list the drives,the corresponding folders
and files in one listbox
private void ShowPath_Click(object sender, EventArgs e)
{
reader = new XmlTextReader("path.xml");
Form1 f = new Form1();
String sp="";
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
String s1;
s1 = reader.Value;
String ss = listBox1.SelectedItem.ToString();
String sss = ss + s1;
object o3 = (object)sss;
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
FileInfo fil = new FileInfo(foldername);
sp =fil.ToString();
}
}
DirectoryInfo di = new DirectoryInfo(sp);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(sp);
foreach (String filename in files)
{
FileInfo fil2 = new FileInfo(filename);
listBox2.Items.Add(fil2.ToString());
}
}
break;
}
}
}
The folders have been listed using:
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
FileInfo fil = new FileInfo(foldername);
[b]sp =fil.ToString();[/b]
}
This statement
listBox2.Items.Add(fil.ToString()); displays all the folders in the listbox.
I want the the listed folders to be sent as a string parameter to the next DirectoryInfo();
So i used sp =fil.ToString();
but it gives me the files present in only 1 folder...
I want to list all the files from all the folders in a drive...
What change should i do for this?
|
|
|
|
|
Directory.GetFiles(FolderPath, "*.*", SearchOption.AllDirectories);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi
I tried with this but still i dont get files from all folders
|
|
|
|
|
Hi,
I am trying to add a couple of new attributes to a TreeNode. I have extended the System.Windows.Forms.TreeNode class and added the attributes i want. I am able to create an instance of my extended TreeNode class ok and get/set the values of the new attributes. The problem i have is how to popluate a TreeView with instances of my extended TreeNode class.
I have tried using the original Nodes.Add() method but i understand this just adds an instance of the original TreeNode class to the TreeView which discards my new attributes.
I believe what i need to do is create my own Nodes.Add() method, is this correct? Is this the best way to acheive what i want to do?
Thankyou
|
|
|
|
|
Jastons wrote: I have tried using the original Nodes.Add() method but i understand this just adds an instance of the original TreeNode class to the TreeView which discards my new attributes
No, you pass a reference. When you add it to the TreeView you just have to pass the reference as a TreeNode. This ref still points to your extended node.
e.g.,
TreeView theTree = new TreeView();
YourNode dummy = new YourNode ();
dummy.YourProperty = 100;
theTree.Nodes.Add(dummy as TreeNode);
YourNode dummy2 = theTree.Nodes[0] as YourNode;
You pass a reference, not an instance.
|
|
|
|
|
That is great, thankyou very much.
|
|
|
|
|
I am trying to allow wrapping of a world map from east to west or west to east (the map is split down the Pacific Ocean). Thus the map would appear to be a cylinder not a rectangle. As the user scrolls across the dividing line the other map edge appears.
I thought this would be resonable but I have not been able to find much searching (map, warpping and scrolling appear in many contexts). Any help would be greatly appericated.
If I should move this to the graphics board please let me know.
Thanks,
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
Hello everyone,
I am writing a simple web method which returns byte[], and the byte[] is encoded by UTF-8. I have investigated related WSDL and soap message, seems the underlying web services stack will use base64 encoding?
For various reasons, I can not use or re-encode my return byte[] from UTF-8 to base64. Any ideas to modify the base64 encoding to UTF-8 encoding?
Here is my related web methods, SOAP message and related type in WSDL
Web service server side code
[WebMethod]
public byte[] HelloWorld2()
{
return utf8encodedbytes;
}
SOAP response
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld2Response xmlns="http://tempuri.org/">
<HelloWorld2Result>base64Binary</HelloWorld2Result>
</HelloWorld2Response>
</soap:Body>
</soap:Envelope>
related type in WSDL
xsd:base64Binary
thanks in advance,
George
|
|
|
|
|
Try this[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You misunderstand my question. Since I pass UTF-8 character in response, but in WSDL it is encoded as base64, there is runtime error which says XXX is invalid value in base64.
So, my purpose is how to change the decoding scheme at client side to treat input as UTF-8 other than base64? Any ideas?
regards,
George
|
|
|
|
|
perhaps this[^] may help...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
I am trying to make a computer version of a homemade solitaire game. I am ok with the logic behind this game but I am not much of a graphics guy. I am looking for help pointing me in the right direction. I want to be able to grab the card and move it to a different pile and I am not sure the best way to do this. The examples that I can find only involve dbl clicking the cards.
Any help to set me down the right path would be appreciated!
|
|
|
|
|
Thats not so hard... you will just need Generic Lists of PictureBox and have to handle MouseDown, MouseMove and MouseUp events
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi there,
I've researched this for two days now and followed guide lines set down from sites such as MSDN, bytes.com, dotnetspider and many others but still no joy.
What I wish to do is have Form1 call Form2 where abouts on certain conditions in Form2 (user event say) a message is written to a text box in Form1. I can't get it to work. Here's some code
public class Form1
{
private System.Windows.Forms.TextBox txtMainMessage;
public Form1()
{
}
public string WriteMainMessage
{
set
{
this.txtMainMessage.Text = value;
MessageBox.Show("from set " + this.txtMainMessage.Text);
this.txtMainMessage.Refresh();
}
get
{
return this.txtMainMessage.Text;
}
}
button_click(args..)
{
}
}
public class Form2
{
private Form1 frm;
public Form2()
{
frm = new Form1();
}
button_click(args...)
{
frm.WriteMainMessage = "This is accessor";
MessageBox.Show("accessor says " + frm.WriteMainMessage);
}
}
TextBox txtMainMessage in Form1 still will not display anything. There are no errors. Is there some redraw I'm missing? As mentioned I tried setting txtMainMessage as public modifier which Form2 could access its Text property directly. Still would not write to textbox. Just as experiment i set a button on Form1 to write to txtMainMessage, that worked (relief). Where does frm.WriteMainMessage in Form2 sit within scope of Form1 TextBox? I wrote a public method in Form1 which Form2 sends a message to. Method set text property of textbox to message, I displayed the contents of TextBox.Text and there was the message! So this.txtMainMessage.Text actually holds the value but will not draw it in the text box itself.
What do you feel I am missing here? Thank you in advance.
Anthony James Lawrence
|
|
|
|
|
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string WriteMainMessage
{
get { return textBox1.Text; }
set
{
textBox1.Text = value;
MessageBox.Show("from set " + textBox1.Text);
}
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
form1 = new Form1();
form1.Show();
}
Form1 form1;
private void button1_Click(object sender, EventArgs e)
{
form1.WriteMainMessage = "This is accessor";
MessageBox.Show("accessor says " + form1.WriteMainMessage);
}
}
I tested this code and found its working as it should...did you called Show() of form1 ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks for reply Xmen, very quick
Show() will open second Form1 window and low and behold the textbox is written to. I don't really want a second Form1 form appearing though. My entry point is Form1 which calls Form2 through button click event. Anyway of just having one form1 form appear once? Is this even possible?ain
Thank you again
|
|
|
|
|
BTW Am using .NET 1.1 no partial classes
|
|
|
|