|
Hi Dave,
This problem happens with ANY exe, mine or anyone else's.
I've also created a new windows forms application (without code) and it behaves the same.
I've also debugged an application, it steps through the code and exits after the last debuggable statement (i.e. when it enters the event handling phase).
I've done this on VS2005 and VS2008.
Just to make it stranger, if I start the application rapidly many times in a row, *some* instances actually stay alive.
Cheers,
Michel
|
|
|
|
|
Sorry I made a small mistake in last post, with "any exe" I mean "any .NET exe".
Cheers,
Michel
|
|
|
|
|
msmits wrote: his problem happens with ANY exe, mine or anyone else's.
Well, you didn't say that in your original post, so how were we supposed to know??
msmits wrote: Just to make it stranger, if I start the application rapidly many times in a row, *some* instances actually stay alive.
In that case, make sure your machine hasn't had a virus introduced, then uninstall and reinstall the .NET Frameworks.
Oops. I just saw your last post. Glad you got it fixed!
|
|
|
|
|
When the application exits in Visual Studio in the debug window I see the message:
The program '[4756] MyTestApp.vshost.exe: Managed' has exited with code
-1073741819 (0xc0000005).
After searching for the error code on search.microsoft.com I found there are quite some people with the same problem. There was one solution listed and it works for me.
The problem is caused by the Kensington Mouseworks software that I have installed. It is very strange indeed but after uninstalling it the problem disappeared.
Cheers,
Michel
|
|
|
|
|
Hi all,
I have a requirement like.. i want develop a tool which will create and add a class library project to a given solution. and also i am able to add a class file to the project with a given name.
Please suggest me how can i do this..
Thanks in Advance.
|
|
|
|
|
First I'd try it manually with Notepad. Once you see the structure of the solution you should be able to write something that uses a System.Xml.XmlDocument to do it.
|
|
|
|
|
Hi Guys,
I've got an app composed of a moderately complicated control hierachy. I have a situation where on selecting a different node in a tree view, i'd like to focus on a seperate control and have that focus bubble up to the primary text box so that it can be edited straight away, however the OnGotFocus method in my custom control never gets called after control.Focus(), so can't be bubbled up the object tree.
Any ideas how to get around this?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Tristan Rhodes wrote: I have a situation where on selecting a different node in a tree view, i'd like to focus on a seperate control and have that focus bubble up to the primary text box so that it can be edited straight away
What is the purpose of the middle control getting involved? Sounds like you are over complicating things.
Tristan Rhodes wrote: I've got an app composed of a moderately complicated control hierachy
I would look into simplifying it. One example would be the Mediator pattern[^]
If you are not familiar with patterns or even this one in particular, don't get bogged down in the details. Look at the description of the pattern, the problem it solves and the basic idea of how. Even if you roll your own and it doesn't match the pattern exactly, it will still be far superior to the tightly coupled approach you seem to be currently engaged in.
|
|
|
|
|
I've got a Treeview for item selection / association and another control for editing / validating the selected item. These form a composite control responsible for managing the Items collection. There are a number of similar style controls (View / Editor combo) with responsibilities for different parts of the application data beside items. These all sit on an observable model which can be modified and kept in sync with the various views and handle the Undo/Redo commands.
I'm trying to get the manager control to handle the Selected event in the tree view / list and pass the focus to the editor control, which in turn would focus on it's main field so the user can edit and tab through the various controls without having to click on it first.
I'm hoping to make this the default behavior for each view, but for some reason the Focus event gets eaten by the Custom control.
EDIT: Ok - so it IS shifting focus, but it's not raising an event or the OnFocus method, and i have no control over what it selects. I thought it was tab index, but it doesn't do anything that i can see.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
modified on Tuesday, April 7, 2009 8:05 AM
|
|
|
|
|
Ok, now I recognize that I can't understand the design as you are stating it.
Tristan Rhodes wrote: There are a number of similar style controls (View / Editor combo)
Tristan Rhodes wrote: These form a composite control
Tristan Rhodes wrote: I'm trying to get the manager control to handle the Selected event in the tree view / list and pass the focus to the editor control
So if this "editor control" is one of your custom controls you should say that rather than editor control which is interpreted as edit control, hence much confusion.
Anyway if I now understand correctly, don't use the focus event. If this is your custom control, in fact they all are I guess, you should have a design that is yours. It could be events or messages it doesn't matter but it should be yours. Don't try to use the framework events as your custom events, that is probably not a great idea even when it works.
This is not a topic I remember Kent Beck covering in Implementation Patterns, but I imagine he would say something like "prefer explicit design to implicit" as it is easier to understand.
|
|
|
|
|
Hi Mike,
I'm not trying to use any custom events, i just want to be able to handle a change of focus on my control so i can implement some specific behavioral logic. It's not (or shouldn't be) a complicated task. I'm happy with the application design as is, and I don't really want to have to implement my own system for something that already exists that just needs a bit of custom tailoring.
To sum up the process:
* User selects MenuItem in treeview
* TreeView raises selected item change
* Selected MenuItem is loaded into MenuItemEditor
* Focus is passed to MenuItemEditor
* MenuItemEditor passes focus to TextBox. //OnFocus / Focus event not hit
* User edits TextBox Text.
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Are you handling an event or overriding OnFocus? If you are overriding the method, do you still call base.OnFocus()?
|
|
|
|
|
I override the OnFocus method as the event wasn't getting raised. The OnFocus method never gets hit either for some reason.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
You'll have to research this a bit I'm afraid. For some reason (there must be something better than anything I can think of) Microsoft has this incredibly elaborate design for this stuff which means simple logical code you'd expect to work just doesn't.
Unfortunately it seems that the TreeView is doing something *after* the *After*Select event that causes the active control to be reset to whatever tree node you were working with.
It's not elegant, but I worked around it using a Timer control and an instance member to refer to the control I want to activate, a la this:
Control ctrlToActivate;
void timer1_tick(object sender, EventArgs e)
{
if (ctrlToActive == null) return;
ctrlToActivate.Select();
ctrlToActivate = null;
}
void tree_afterSelect(object sender, TreeViewEventArgs e)
{
tabControl1.SelectedIndex = int.Parse(e.Node.Tag.ToString());
foreach (Control c in tabControl1.SelectedTab.Controls)
if (c is TextBox) { ctrlToActivate = c; return; }
}
The timer event is on the UI main thread so basically the message loop of the window will call the handler whenever it's doing an iteration and finds that the timer's interval has expired. It's not really expensive so you can use a short interval like 30 milliseconds, but there surely ought to be a much easier way to achieve this. I can only suggest you study the model because clearly focus and selection and "currently active control" are related but not identical concepts.
Finally, a word on terminology. I wouldn't call this bubbling. Your control is a container that when receiving focus (or perhaps when "being activated" which apparently is not the same thing) should in turn activate/focus a particular child control. Bubbles rise - and I think most people think of event bubbling the way it works in DHTML: An event occurs on a control, and if there's a handler registered with the control for the event it executes. Then the event may bubble to the parent control of the "event source", and again handlers may execute. This allows the user to attach a handler to a container and handle events that originate in the child controls - such as a mouse click anywhere in a table without having to register handlers with every row, cell, and content controls inside it. What you're doing is pretty much the opposite - you're not bubbling an event to a handler somewhere up the control tree, but rather "rippling the event" or causing a domino effect so that when the event occurs on the parent it also occurs on a child.
I'm fairly amazed at how complicated Microsoft sometimes manages to make even the functionally/conceptually simplest of tasks. To be fair, with .net they've often made it easy to do formerly complicated things, but this is frankly ridiculous. Trying to find anything in the documentation is awful - you have to take bits and pieces from Control, ContainerControl, the IContainerControl interface for container controls that don't inherit from ContainerControl (such as the TabPage, which inherits from Panel, ScrollableControl, Control, object -- meaning the Panel isn't a ContainerControl either..!?!), Form.ActiveControl, and more, and consolidate the reference-style information here into something that resembles a logical model for controlling what control is active in your application. Maybe the nature of the problem really is so intricate and complex that this is to be expected, or maybe Microsoft did a truly bad job with this part of the FrameWork. Or maybe (my real hypothesis) it is necessary to conform to certain *windows* (as opposed to .net) concepts that are hideously complicated and make it impossible to come up with a simple way to activate a textbox when a user clicks a node in a tree. One would not think this should be hard, but just google for Focus() and Select() and "active control" and "set focus .net windows forms" and you'll quickly see that a LOT of people are finding this a daunting task.
|
|
|
|
|
I did some digging and realised that the focus was changing, but changing back again. It swapped focus OK when i right clicked and the ContextMenu comes up, but if i Mouse Down, the focus changes, and MouseUp it changes back again. A real pain.
In addition, the OnFocus doesn't get called anywhere. Argh, i hate UI stuff, it takes up 80% of the development time to get the event system working just the way the end user wants Thankfully it's not an urgent priority, so i'm, going to put it on a back burner.
Cheers for the pointers though.
And how about focus cascading? I Wasn't sure what to call it and i'd just watched Finding Nemo
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Hi Guys,
I'm having problems with Process.Start, if i give it just the .exe path, it works fine, if i try to add a following string after it to specify a file to be opened by the .exe, it throws a FileNotFound exception in .Net.
i.e:
Ok -
Process.Start("C:\\Temp\\My.exe");
File Not Found -
Process.Start("C:\\Temp\\My.exe \"C:\\Temp\\MySampleFile.xml\"");
Both files exist, it works fine if i copy it into Command line or use Run.
Any idea how to get around this?
Cheers
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
|
DOH!
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Hi,
I have 2 websites build in .NET hosted on same server, using same database SQL Sever 2005.
Now when I browse through in any of these sites, after randomly browsing through different page, the site gets hanged and after few minutes I got Time Out error.
The Description of error is as follows
The following error was encountered:
* Read Timeout
The system returned:
[No Error]
A Timeout occurred while waiting to read data from the network. The network or server may be down or congested. Please retry your request.
Please help, I was struck into this since last couple of days.
|
|
|
|
|
Okay - So you have to decide how you want your application to react when it receives a time out error. I would suggest you either allow it to gracefully degrade the functionality (if the specific feature is a nice-to-have) or inform the user that their request could not be honoured.
If it is happening in SQL Server you may want to consider optimising your queries or database if that is taking a long time to return answers to your queries.
|
|
|
|
|
Hi,
I need to know that, is .net framework required to run a windows service, which was created using Visual Studio 2005?
Thanks in advance...
Subin.
|
|
|
|
|
Yes, the framework is required to run .NET assemblies
I are troll
|
|
|
|
|
Not if you used Visual Studio 2005 to write it in unmanaged code.
|
|
|
|
|
There is an interesting project:
www.codeproject.com/KB/IP/Modbus_TCP_class.aspx
Could someone please tell me what software I need to open and run this project code? Obviously, I have given myself away as someone who knows very little about programming. Actually, I have quite a lot of experiance with VB6 so I am nota complete novice.
Thanks in Advance,
Johnny
|
|
|
|
|
Hi,
the article's header and download indicate it was programmed in C# using Visual Studio 2003, which got superseded by VS2005 and later by VS2008. If you don't have any of those available, the best you could do is download the free "Visual Studio 2008 C# Express Edition" from the Microsoft website (it needs the .NET Framework 3.5 present on your development system; that too is freely downloadable).
When launching the project, it will convert it to the latest file format automatically; from then on it should work as intended.
Assuming you are unfamiliar with both the .NET Framework and the C# programming language (a successor to object oriented languages such as C++ and Java) I strongly suggest you buy a tutorial book on C# and study that before you start any C# programming yourself.
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
|
|
|
|
|