|
I forgive your stupidity
Thank you very much. I guess I'll conquer this problem.
|
|
|
|
|
i have a class
public class Command
{
public int Number;
public int Parameters;
}
then 1 xml file :
<common>
<command number="0">
<response parameters="2">
<command number="1">
<response parameters="5">
i wanna assign attribute of the class to value in xml file:
Command[] Response = new Command[200];
XmlDocument Reader = new XmlDocument();
Reader.Load("Sample.xml");
XmlNodeList List = Reader.SelectNodes("/Common/Command");
foreach (XmlNode commandnode in List)
{
int i = int.Parse(commandnode.Attributes["value"].InnerText);
Response[i] = new Command();
HartResponses[i].Number = i;
XmlNodeList Child1List = commandnode.ChildNodes;
foreach (XmlNode Child1 in Child1List)
{
if (Child1.Name == "Response")
Response[i].Parameters = int.Parse(Child1.Attributes ["Parameters"].InnerText);
}}
i got error :"Object reference not set to an instance of an object" at the line
Response[i].Parameters = int.Parse(Child1.Attributes["Parameters"].InnerText);
The code can be executed with i=0,but when i increase to 1, i got this error?
How do i solve it?
Thanks
|
|
|
|
|
hung1984 wrote: Command[] Response = new Command[200];
This creates an array of 200 instances of null. Each must be created before you assign values to it.
Response[i] = new Command();
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
they are already created here:
foreach (XmlNode commandnode in List)
{
int i = int.Parse(commandnode.Attributes["value"].InnerText);
Response[i] = new Command();
HartResponses[i].Number = i;
.............
|
|
|
|
|
Any code that assumes a child node exists, is bad code. I guess this attribute is not always there.
A good way to debug this code is to break it up into as many lines as possible, and see which line blows up. The debugger is also a powerful tool.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i use it cause my xml file surely have the node named Response. But why the error started with Response[1]?
|
|
|
|
|
I assume because that's the one that doesn't have the attribute. Hard to say, I don't see your XML, and you don't say if you did what I told you to do to work out the exact problem.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
thanks a lot. I think there's some mistake with my xml file
|
|
|
|
|
high i am learning crystal reports and have looked at some articles here to find how to create a crystalviewer, after i add a new item(Crystal Report item) i can not see the designer! i just have "myreport.rpt" and "myreport.cs" in my solution explrr. when i double click on "myreport.rpt" it shows me some hex codes and when i d-click on "myreport.cs" it tells me to drag item from toolbox!
how i can launch the designer and add tables and etc....?
|
|
|
|
|
I'm trying out remote debugging from a WinXP Pro machine to a Win 2003 Server machine (where the source code is deployed).
When I try to compile from Visual Studio 2008, the following error is displayed:
Error 1 'CaseTrak.Activities.StatusUpdater.CTSetCaseReviewStatus(string, int)' must declare a body because it is not marked abstract, extern, or partial z:\Projects\CaseTrak.Activities\CaseTrak.Activities\StatusUpdater.cs 37 21
<code>
public bool CTSetCaseReviewStatus(string sCaseID, int iStatus)
<code>
</code></code>
Resolution (http://msdn.microsoft.com/en-us/library/bb397743.aspx[^])suggests to me that get and set methods have to be set for the variable type, however, it does not seem to fit within the context.
Any ideas?
// cs0840.cs
// Compile with /target:library
using System;
class Test
{
public int myProp { get; } // CS0840
// to create a read-only property
// try the following line instead
public int myProp2 { get; private set; }
}
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using CaseTrak.WebServices;
namespace CaseTrak.Activities
{
public partial class StatusUpdater: SequenceActivity
{
public StatusUpdater()
{
InitializeComponent();
}
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
try
{
}
catch (Exception ex)
{
}
return ActivityExecutionStatus.Closed;
}
public bool CTSetCaseReviewStatus(string sCaseID, int iStatus);
}
}
Jon
|
|
|
|
|
Hi
As you know a class can have fields,methods,properties and events.In general ,methods are behaviors and fields are attributes of a class.(Properties are some special methods to control accessing to the fields according to the encapsulation rule) therefore if there's a behavior (method or property) it should be implemented (or as the exception says should have a body using brackets) unless it's either an abstract method in an abstract class that it's inheritor should implement it and thus it should not have a body or an external method (a placeholder for a windows API method)
The problem here is that you have a CTSetCaseReviewStatus method that has no body.You can change it like this:
public bool CTSetCaseReviewStatus(string sCaseID, int iStatus)
{
}
|
|
|
|
|
hi friends
How do i add/merge 2 hashtables into third hashtable
Tejesh
|
|
|
|
|
If there's no method for this, you can iterate over the Keys and use those to copy the values in.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
If you use .NET 3.5 then you can use the Union method:
Dictionary<int,> dicA = new Dictionary<int,>();
dicA.Add(1, 10);
dicA.Add(2, 20);
dicA.Add(3, 30);
Dictionary<int,> dicB = new Dictionary<int,>();
dicB.Add(3, 35);
dicB.Add(4, 40);
dicB.Add(5, 50);
var newDic = dicA.Union(dicB);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
i have developed a custom control that have some property to show/hide its child controls. When i set their Visible prop to False the get Hide. But when i run it or just reopen that control they appear again. Any solution ?
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
Can you send us some code ?
|
|
|
|
|
didnt think it would need, well here is it.
public bool ShowThing
{
get { return picturebox1.Visible; }
set { picturebox1.Visible = value; }
}
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,
Unfortunately I couldn't get you. What do you mean by Run It? Or Reopen It?
When you create a new instance of a Control (User Controls too) its properties got their default values (I hope I could tell it right).
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
i know that...'run it' mean run the application
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
|
|
|
|
|
Ummm... So you set the ShowThing value to false but when you run your application they're visible?
Maybe you changed some values in PropertyBinding or DataBinding. Make sure their values are set to none.
I have a UC like you. It has a property named TextMultiLine, here:
public partial class LabeledTextBox : UserControl
{
public bool TextMultiLine
{
get { return txtText.Multiline; }
set { txtText.Multiline = value; }
}
}
And I have no problem with it:
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
LabeldTextBox ltxt = new LabeledTextBox();
ltxt.TextMultiLine = true;
}
}
I think your problem is in somewhere else. I hope you can find it
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
dude, its works after InitializeComponent() called but not before. Dunno whats the cause
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
|
|
|
|
|
Do you by any chance have a private field that looks like this?
private bool ShowThing = true;
I are troll
|
|
|
|
|
it wont showup in propertygrid
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
|
|
|
|
|
[Browsable(true)]
public bool TextMultiLine
{
get { return txtText.Multiline; }
set { txtText.Multiline = value; }
}
This?
I are troll
|
|
|
|
|
well, i got it work...I just needed to make a bool variable that hold the value and i return its value in property and in set i set both(the visible property and that variable). It worked like charm
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
|
|
|
|