The exception stack trace shows that it is thrown somewhere in AxHost class. Unfortunately, I am not at my work place right now, so cannot attach the exact StackTrace. But will update as soon as I get it.
To explain further, I am writing the code flow that is something like as follows
// Main<br />
/*Line 1*/ VisioForm f = new VisioForm();<br />
/*Line 2*/ f.Show();<br />
/*Line 3*/ f.Close();<br />
/*Line 4*/ MyApplicationContext c = new MyApplicationContext; <br />
/*Line 5*/ Application.Run( c );<br />
There is a button on MainForm that has the same code as mentioned in Line 1-3 above in its click event. Now If I comment the code as in Line 1-3, the application will crash if the button on main form is clicked. But works fine, if I leave it there.
More interestingly, If the lines 1-3 are moved between line 4 and 5, the application will still crash with the same message.
This makes me believe that there is something wrong when using ActiveX controls inside a custom application context on Vista.
1. Yes, it is form.Show() and form.Close(). This is actually a work around to make the application work on Vista. After placing these lines, VisioForm opens fine whenever the button on MainForm is clicked.
2. The code does has try-catch. Problem is I cannot get my form open. I will put the exception log here.
3. Main module has STA Attribute.
Actually if I open and close the form containing Visio control (Line 1-3 in my previous post), before application context initialization, my application works fine on Vista. but If I remove these lines, it starts crashing whenever the VisioForm is initialized.
Hi Guys. I have an opendiledialoge. If I click Cancel then the whole project closses. Any idea how I can set it to return to the main form if the user clicks on cancel instead of having the whole app closing??
Here is the code.
if (openFileDialog1.ShowDialog() != DialogResult.OK)
Excellence is doing ordinary things extraordinarily well.
adding to what PIEBALD told you, I find it rather strange that your program would
do something when CANCEL is clicked; normally cancel means "don't do anything, since I have
changed my mind". This also means you should NOT close the form itself.
I trust the above is part of the Microsoft recommendations for a Graphical User Interface.
I am developing an application where multiple users will have concurrent access to a database for reads, writes/adds, deletes and updates. Much of the user interface will be through the DataGridView control. I am trying to come up with as elegant a solution as possible to dynamically update a DataGridView for, say, User #2 if User #1 makes a database change to the same table that User #2 is viewing. It seems that I have to programatically refresh the grid no matter how I have it bound to the database (connected or disconnected recordsets). Am I missing something? Is there something in ADO.Net that will enable me to bind data to a grid such that any changes to the database will almost immediately be reflected in the grid with no forced/programmatic refresh?
No There is no such facility. The closest thing to what you want is SQL Server Notifications, but that is cumbersome and overkill here.
Your idea to update user1 of changes by user2 may not be as good a design as you think. Some questions to consider:
1. How likely is it that multiple users will be modifying the same data?
2. What is the likelyhood they will be viewing the same data (same subset of rows in the same table).
3. If user1 edites field A of row 2 just as your update notification arrives for User B having done the same, what will you do - overwrite user1's change? how annoying might that be?
In most cases both 1 and 2 are relatively rare, so all the network round trips needed to even determine if users need to be synchronized is not worth the negative impact on performance and scalability. The normal practice here is to detect collisions only when the user commits changes, and refuse them if the modified data had additional changes after the first user read them, but before he posted changes (typically by adding a timestamp field to each row, and comparing the timestamps - only allow update if they are still equal).
From the help on SqlDependency Class:
" SqlDependency was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have SqlDependency objects set up for a single database server."