|
According to http://msdn2.microsoft.com/en-us/library/system.stackoverflowexception.aspx[^]...
<br />
In prior versions of the .NET Framework, your application could catch a StackOverflowException object (for example, to recover from unbounded recursion). However, that practice is currently discouraged because significant additional code is required to reliably catch a stack overflow exception and continue program execution.<br />
<br />
Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default.<br />
Does that help?
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means?
|
|
|
|
|
Thank you, I have also read that and that gave me no hope. So the best is to switch back to Framework 1.0
I cannot believe there is no way to catch such a fatal exception.
I have tried to create a new AppDomain…
I have tried to start the whole app in a separate Thread…
But everything I do the application still crashes.
|
|
|
|
|
I am using Treeview in a C# windows form. The data entered into the tree is a hierarchical listing of table definitions associated in groups of various depth off of the Treeview root.
I am looking for a class or routine where I can navigate through each Treeview node and node/child, get the value of the element so i can process the output.
I have a rudimental listing of this through the first 2 nodes (with testing ), but this requires some more elaborate coding, maybe recursive:
<br />
String nodeName = "";<br />
int nodeNum = 0;<br />
int i = 0, j = 1, k=0, cnt=0, lstNode=0;<br />
nodeName = treeView1.ToString();<br />
if (treeView1.Nodes.Count > 0)<br />
{<br />
for (i = 0; i < treeView1.Nodes.Count; i++)<br />
{<br />
nodeName = treeView1.Nodes[i].Text.ToString();<br />
cnt = treeView1.Nodes[i].GetNodeCount(false);<br />
if (cnt > 0)<br />
{<br />
lstNode = treeView1.Nodes[i].LastNode.Index;<br />
lstNode = treeView1.Nodes[i].LastNode.Level;<br />
for (j = 0; j < cnt; j++)<br />
{<br />
try<br />
{<br />
nodeName = treeView1.Nodes[i].Nodes[j].Text.ToString();<br />
}<br />
catch (Exception e)<br />
{ <br />
nodeName = "Undefined"; <br />
}<br />
}<br />
}<br />
}<br />
}<br />
This needs to be refined so that I can see ALL child elements no matter how deep they are in the Treeview.
Can anyone help?
|
|
|
|
|
You will need to write a recursive function to iterate through all nodes of a treeview
|
|
|
|
|
That is my assumption as well, but I have not written a recursive function in quite awhile. Can anyone give me push in the right direction on this? Code samples or what not?
|
|
|
|
|
Without wanting to get into the exact details of the code, it would normally look like this:
public void WalkNode(TreeNode node)
{
if (node.Nodes != null)
{
foreach (Node child in node.Nodes)
{
WalkNode(child);
}
}
}
|
|
|
|
|
Thank you very much. I was ot looking for the exact details of the code segment, just the outline for now. It has been a long time since doing any recursive programming (avoid like the plague) and am out of practice.
Thanks again.
|
|
|
|
|
Is it possible to find the name of the property for which an instance of an object is assigned to? ie: From inside an instance of an object that is assigned to a property of another object, I want to know the name of the property that that object is assigned to?
For example, you have a "Person" class that has a "MailingAddress" property and a "ShippingAddress" property, with each of these containing a general "Address" class object. From inside the instance of the "Address" object that is assigned to the "ShippingAddress" property, how do I find that this instance is assigned to the "ShippingAddress" property or the "MailingAddress" property? Or more generally, how do I find the name of the property for which an instance of an object is assigned to?
I would like to be able to do this without having a reference to the parent "Person" object; just determine the declaring property's name from any instance of an object.
Ultimately, I would like to define a string that contains the "path" down through an object hierarchy from property to property. For example, create a path string such as: "Person.ShippingAddress.ZipCode", which can be parsed later to in order to set the "ZipCode" property to a specific value for a Person. This example is somewhat trivial, but I need to be able to create this "path" for any object in order to set that object's property values for testing purposes. ie: Given that I know I will start with some parent object (in this case a Person object), I want to parse the path string so I can drill down through the Person class in order to set certain property values and then test the reaction of the program to those newly set values. Having the path string allows me to automate this testing process.
Reflection seems to work well when you want to drill DOWN into a class, but how to you start with an instance of an object and work your way back UP?
Thankyou for your time. Joby
|
|
|
|
|
I forget the details, but it's possible to get a call stack in code, I believe.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You could always use the Stack for this. Try looking at the StackFrame class for this.
|
|
|
|
|
I am on my way towards building my own "Automated Call Distribution", IF any has any clue for CTI or TAPI in .net 2.0 please let me know.
Thank you!
M. Nauman Yousuf
"Mess with the Best, Die like the rest"
|
|
|
|
|
Im writing a windows service in c# vs2003 that does a lot of io on file
reading files writeing files and more the problem is
the performance of the program is not so good
1. can some opne direct me to material about io best practices
2. is there free tools to analyse the code so i can track the problematic portion of the code
thanks
|
|
|
|
|
How are you using the IO? Do you have any code? IO will be slower in a managed context compared to a C memory-mapped file but I have never really had much of a problem with file IO in C#.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I need in-depth WorkFlow Foundation DependencyProperty samples, articles or explanations,
(for creation state workflow , whose activities are connectable to external .NET objects, WinForm's controls, arrays or DataRows in DataTable .)
Are there in-depth samples for DependencyProperty ?
thanks you
_______________________________
something I have:
http://odetocode.com/Blogs/scott/archive/2006/07/27/5444.aspx
DependencyProperty Activity binding
http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,0fae3e73-7801-4cf6-a5a5-9370b0f99973.aspx
is that the configuration mapping will control what page is next in the flow,
http://blog.hackedbrain.com/articles/UnderstandingDependencyObjectAndDependencyProperty.aspx
Ramblings from a compromised
|
|
|
|
|
I'm trying to run a web application inside a webbrowser component and I get java runtime errors, Those erros doesn't append when running into internet explorer 7.
The c# application I created is simply a window with a webbrowser in it, nothing else.
Jackd
|
|
|
|
|
I have installed an application on several xp machines. They all seem to be working fine.
Except one machine which has windows 2000. The application works but it is slow and sometimes it gives the following error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Please note that in sql server 2005 Local and Remote connections is selected using tcpip
Any thoughts why only this machines sometimes gives this error when connecting to the sql server 2005 please?
Thanks
|
|
|
|
|
Try updating the MDAC components to the latest. YOu can get that here[^].
|
|
|
|
|
Hi all,
Can anyone tell me what happens (in the stack context) to the value type "x" after Init() method has been terminated:
--------------------
delegate void TestDelegate(ref int x);
class Program
{
static void Main(string[] args)
{
Init();
Console.WriteLine("Waiting");
Console.Read();
}
static void Init()
{
int x = 123;
int y = 123;
int z = 123;
TestDelegate t = new TestDelegate(TestFunc);
t.BeginInvoke(ref x, null, null);
}
static void TestFunc(ref int x)
{
Thread.Sleep(1000);
Console.WriteLine(x);
}
}
--------------------
Thanks,
________________________________________________________________
There are 10 kind of people: those who knows binary and those who doesn't.
|
|
|
|
|
|
Thanks!
Looking at the article, I figure out that passing int ref parameter (like Figure 13 example) will cause the value to be boxed - if the value is assigned to a object field - or simply copied - if the value is assigned to a int field - just like my example does.
Just assign some another value to "i" after BeginInvoke call and it will not affect the result.
The question is: Does the delegate class created has a "int" type or an "object" type to hold the value?
________________________________________________________________
There are 10 kind of people: those who knows binary and those who doesn't.
modified on Wednesday, December 05, 2007 2:44:19 PM
|
|
|
|
|
I'm trying to use P/Invoke to marshal some legacy code. I either get an "Entry Point Not Found" error, or a "Memory access violation"
I've run dumpbin on this dll, and i've verified that the entry point exists. I'm lost.
Here's the source for the function I'm exporting..
extern "C" BOOL FindUser2(char *cpUserFile,
char *cpPassword,
char *cpUserName,
char *cpUserPriveledge,
char *cpUserID,
char *cpComments,
BOOL *bUserActive,
char *cpErrorReason)
{...}
Here's my pathetic attempt to marshal it.
[DllImport("WN_USER_SECURITY.dll",EntryPoint="FindUser2") ]
public static extern bool FindUser2(
[MarshalAs(UnmanagedType.LPArray)]char[] strFileName,
[MarshalAs(UnmanagedType.LPArray)]char[] strUserPassword,
[MarshalAs(UnmanagedType.LPArray)]char[] strUserName,
[MarshalAs(UnmanagedType.LPArray)]char[] strUserPriveledge,
[MarshalAs(UnmanagedType.LPArray)]char[] strUserID,
[MarshalAs(UnmanagedType.LPArray)]char[] strUserComments,
[MarshalAs(UnmanagedType.Bool)] bool bUserActive,
[MarshalAs(UnmanagedType.LPArray)]char[] strErrorReason);
|
|
|
|
|
Try marshalling your char[] as StringBuilder objects instead.
|
|
|
|
|
Hi
first, as pete pointed out already it's a good idea to pass the char* with a string builder.
second, the BOOL *bUserActive looks to me like a ref value. so you might have to change your call as follows:
[DllImport("WN_USER_SECURITY.dll",EntryPoint="FindUser2") ]
public static extern bool FindUser2(
StringBuilder strFileName,
StringBuilder strUserPassword,
StringBuilder strUserName,
StringBuilder strUserPriveledge,
StringBuilder strUserID,
StringBuilder strUserComments,
[In,Out ]ref bool bUserActive,
StringBuilder strErrorReason);
it might work without the marshalAs Attributes because on "normal" datatypes, the clr automatically marshals the data correctly.
hope this helps
m@u
|
|
|
|
|
Well, I still can't get past the "Entry point not found" exception. I've examined the DLL using dumpbin and Dependency Walker, and they both show the entry point "FindUser2" as existing at ordinal 1. For some reason the C# app just wont see it.
|
|
|
|
|
Did you get the exception in application run or in method calling?
________________________________________________________________
There are 10 kind of people: those who knows binary and those who doesn't.
|
|
|
|