473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Instruction pointer not going pass the other line

i am trying to add nodes to a node dynamically ... and assign its
proerties to a node objects stored inside the array.... when the
ShapeAdded event is fired... ...inside the if block... instruction
pointer does not go pass the other line...

Can anyone tell me what is the reason? and how to solve this
problem ?
here is the code:

private void shapeAddedToPageEventHandler(
Microsoft.Office.Interop.Visio.Shape addedShape) {
Master vsoMaster = addedShape.Master;

//Check whether the shape has a master. If not,
//the shape was created locally.
if (vsoMaster != null)
{
//Check whether the master is "Ellipse".
if (vsoMaster.Name == "Ellipse")
{
nodeArray = new Node[NodeLimit]; // instruction pointer
does not go pass the first line
nodeArray[NodeCount].Name = "Node" +
NodeCount.ToString();
nodeArray[NodeCount].Id = NodeCount.ToString();
addedShape.Name=(string)"Node" +
NodeCount.ToString(); // Ellipse01
addedShape.Text = (string)"Node" +
NodeCount.ToString();

MessageBox.Show(addedShape.Name.ToString());
NodeCount++;
}

Need help
Regards
Nov 17 '07 #1
3 1271
Are you doing this in an event handler for a windows forms control? If
so, I suspect that an exception is being thrown somewhere and it is being
swallowed by the control firing the event.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"weird0" <am********@gmail.comwrote in message
news:f8**********************************@l22g2000 hsc.googlegroups.com...
i am trying to add nodes to a node dynamically ... and assign its
proerties to a node objects stored inside the array.... when the
ShapeAdded event is fired... ...inside the if block... instruction
pointer does not go pass the other line...

Can anyone tell me what is the reason? and how to solve this
problem ?
here is the code:

private void shapeAddedToPageEventHandler(
Microsoft.Office.Interop.Visio.Shape addedShape) {
Master vsoMaster = addedShape.Master;

//Check whether the shape has a master. If not,
//the shape was created locally.
if (vsoMaster != null)
{
//Check whether the master is "Ellipse".
if (vsoMaster.Name == "Ellipse")
{
nodeArray = new Node[NodeLimit]; // instruction pointer
does not go pass the first line
nodeArray[NodeCount].Name = "Node" +
NodeCount.ToString();
nodeArray[NodeCount].Id = NodeCount.ToString();
addedShape.Name=(string)"Node" +
NodeCount.ToString(); // Ellipse01
addedShape.Text = (string)"Node" +
NodeCount.ToString();

MessageBox.Show(addedShape.Name.ToString());
NodeCount++;
}

Need help
Regards
Nov 17 '07 #2
On 2007-11-17 03:22:00 -0800, weird0 <am********@gmail.comsaid:
i am trying to add nodes to a node dynamically ... and assign its
proerties to a node objects stored inside the array.... when the
ShapeAdded event is fired... ...inside the if block... instruction
pointer does not go pass the other line...

Can anyone tell me what is the reason? and how to solve this
problem ?
No, no one can. You haven't provided nearly a complete enough example,
and based on the code you did post it seems likely that this is more a
question about using interop with Visio than it is a C#/.NET question.
You'll have better luck posting your question in a newsgroup specific
to the automation of Visio.

That said, most likely some sort of exception is happening on that
line. You didn't even post enough code to show what type "Node" is,
but if it's a value type, it's possible there's something in the
default constructor for the type that is causing an exception. If it's
a reference type, then the rest of the code doesn't make any sense,
because you haven't initialized the array, just allocated it. And of
course, it's always possible NodeLimit is too large and the array
allocation simply fails.

It's possible the problem is one of those things, or something else
completely. There's no way to say for sure given the code you posted.

Pete

Nov 17 '07 #3
weird0 wrote:
i am trying to add nodes to a node dynamically ... and assign its
proerties to a node objects stored inside the array.... when the
ShapeAdded event is fired... ...inside the if block... instruction
pointer does not go pass the other line...

Can anyone tell me what is the reason? and how to solve this
problem ?
here is the code:

private void shapeAddedToPageEventHandler(
Microsoft.Office.Interop.Visio.Shape addedShape) {
Master vsoMaster = addedShape.Master;

//Check whether the shape has a master. If not,
//the shape was created locally.
if (vsoMaster != null)
{
//Check whether the master is "Ellipse".
if (vsoMaster.Name == "Ellipse")
{
nodeArray = new Node[NodeLimit]; // instruction pointer
does not go pass the first line
That is not entirely true. The instruction pointer will go to the next
line, where a NullReferenceException occurs, and the method is exited.

You have created an array of Node references, and each reference in the
array is assigned the default value for a reference, which is null.

You have to create actual Node objects and assign to the array before
you can use them.
nodeArray[NodeCount].Name = "Node" +
NodeCount.ToString();
nodeArray[NodeCount].Id = NodeCount.ToString();
addedShape.Name=(string)"Node" +
NodeCount.ToString(); // Ellipse01
addedShape.Text = (string)"Node" +
NodeCount.ToString();

MessageBox.Show(addedShape.Name.ToString());
NodeCount++;
}

Need help
Regards

--
Göran Andersson
_____
http://www.guffa.com
Nov 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Trogdor | last post by:
I set up a server on an AMD 650 machine running gentoo linux. I installed Apachie 2, MySQL 4.1 and PHP 4.3.11 I use another computer on my local net (192.168.0.x) to access the server as a...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
8
by: kathy | last post by:
If I have 2D array like: int **p; p = new int*; for(int i=0;i<10;i++) { p = new int; }
51
by: Kuku | last post by:
What is the difference between a reference and a pointer?
26
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I...
24
by: Kavya | last post by:
int main (){ int a={{1,2,3},{4,5,6}}; int (*ptr)=a; /* This should be fine and give 3 as output*/ printf("%d\n",(*ptr)); ++ptr;
6
by: gwell | last post by:
Hi, I have a C# assembly that is calling directly into C++ unmanaged code. Everything is working fine but at the very end of the process I get an application error, which says: "The...
9
by: Morten Lemvigh | last post by:
Is it possible to pass a pointer to a constructor or a class definition as argument to a function? Maybe in a way similar to passing function pointers...? The function should construct a number...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.