|
I'm getting very often but not always some kind of error dialog when I quit my app in C# that uses some COM objects. Unfortunately I can't tell what it is because when it pops up the application closes in like 10th of a seccond and I can't see what's the dialog about. This is release build. Debug doesn't report anything in debugger on exit ever. I understand it's very vague but I still need help and hope someone here can help me. How to catch the error?
Thanks a lot for help in advance!
|
|
|
|
|
Hi!
Have you tried catching a ThreadException in your main thread?
Could be worth a try...
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Yeah. But exception seems to pop up after main - when GC is collecting - i'm thinking - and there's no way to trap that.
|
|
|
|
|
It is possible to set a break point at the bottom of your main on Closing for the main form. Or if worse comes to worse, create a temporary button that behaves like "Quit" with your break point there.
|
|
|
|
|
But exception seems to pop up after main in - when GC is collecting - i'm thinking - and there's no way to trap that.
|
|
|
|
|
Try catching the exception raised by Application.Run() in a try catch block or handle the Application.ThreadException event.
Graham
|
|
|
|
|
I too periodically see an error dialog flash when I quit my application. It seems to have started after I overrode WndProc to perform some custom drawing in a List View control, and doesn't seem to occur with any consistency. My gut says the window handle is being disposed while some of the painting routines are using it, but in all honestly I don't know enough and shouldn't even speculate.
If you find a way to "capture" what the error dialog says, let me know.
Regards,
Chris
-- modified at 23:42 Monday 24th April, 2006
|
|
|
|
|
I think, that you've forgot to dispose some GDI+ objects. For example, Graphics
Best regards, Alexey.
|
|
|
|
|
I think, that you've forgot to dispose some COM objects. Try to set them null value.
To see this error, try to set Thread.Sleep(time); after Application.Run(...) with time in milliseconds.
Best regards, Alexey.
|
|
|
|
|
but shouldn't they be disposed when the applciation quits? what is the GC for then? In any case I think I do set them to null and even call ReleaseComObject - no help

|
|
|
|
|
i want to create a tipical bar that appear when i try to move a separetor for example.
It appear with the oppost color of the image above.
How?
|
|
|
|
|
|
tnx but i don't know how delete the line i've drawed...
|
|
|
|
|
As mentioned in the page to which I posted the link, you call the DrawReversibleFrame method a second time (passing in the same Rectangle as the first call) to erase the frame.
Josh
|
|
|
|
|
Hi and THANKS a lot in advance.
I'm getting this error in a different scenario, and I'm in a big urge to get this done, so please MS people and guys of the forum, any help is greatly appreciated.
I'll use a simplified scenario of my case, but the error happens the same. I'm creating a new User Control, I add a DataGridView to it, that's the only control in it. I then create a public property called "Columns" to expose the DataGridView Columns property so I can access the property to the Designer Editor. I do that this way:
namespace WindowsApplication3
{
public partial class myUC : UserControl
{
public myUC()
{
InitializeComponent();
}
[Editor("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[MergableProperty(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView1.Columns; }
}
}
}
I took all that Attributes code from the System.Windows.Forms.DataGridView metadata, just as the Columns property appears in it.
Then, I add a Windows Forms item to my application and drag&drop one MyUC control from the toolbox into it. Then I click the MyUC and go to its properties page to modify the Columns properties just as with an ordinary DataGridView. The property is there but when clicking on its "..." button to open de Edit Columns Dialog I get the mentioned error. Something like this:
"Unable to cast object of type 'WindowsApplication3.myUC" to type "System.Windows.Forms.DataGridView".
I really really need the Columns property to be accesible in Design Time this way. I don't know how to work this out.
As I said, I get this error with an almost blank project. Just add a User Control Item, put a DataGridView into it. Ade the code above to make the Columns property visible and then try to access the property in the Property page.
Thank you so much in advance.
F.
PD: I'm using the shipped VS.NET 2005.
-- modified at 12:47 Monday 24th April, 2006
|
|
|
|
|
It seems that the DataGridViewColumnCollectionEditor is receiving an argument which it expects to be a DataGridView, but is instead receiving an instance of your UserControl. You have two options:
1) Expose the DataGridView as a property of your UserControl, instead of the Columns property. Through that property you can access the columns in the grid.
2) Derive from DataGridViewColumnCollectionEditor and make your sub-class work properly with your UserControl. You can use Lutz Roeder's Reflector tool to investigate how the DataGridViewColumnCollectionEditor works, and tweak your code so that it plays nice with the UserControl. Then modify the EditorAttribute on the Columns property so that it references your UITypeEditor, instead of the MS version.
Josh
|
|
|
|
|
Hey Josh, thanks for your quick response.
I had tried your suggestion 1 before, and I did it again with this simplified scenario. I get the "Object not set to an instance of an objet" error when clicking on the Columns Property of the exposed DataGridView property in my User Control.
Should I do something somewhere so it's initialized for Design access?
As for your suggestion 2, where do I find that Lutz Roeder's tool?
Thanks again.
|
|
|
|
|
I'm not sure what the problem is with the UITypeEditor. That sounds like something which requires detailed investigation to see what's wrong.
Reflector can be found here: http://www.aisto.com/roeder/dotnet/[^]
Josh
|
|
|
|
|
Thanks Josh again.
I really need this to work, I'm on a urge.
Sorry if I'm abusing you but could you please, try my scenario, it's quite simple and quick to set up (see my first post), and try the two paths that are leading me to this 2 different errors?. Maybe you can figure something out.
The 2nd suggestion you made sounds like a lot of work to have something that should be quite simple since all I'm trying to use is a built-in editor: the DataGridView Columns Editor.
I really appreciate your help so far, and I understand if you can go any further.
thank you and than anyone else who can give some light.
F.
|
|
|
|
|
I looked into this issue and discovered that you need to use attribute redirection to accomplish your goal (well, partly at least).
[AttributeProvider( "System.Windows.Forms.Design.DataGridView", "Columns" )]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView1.Columns; }
}
In case you're curious where to find out more about this topic, check out this[^]
Unfortunately, it still does not work correctly. When you try to add a column, it throws another error message. But, at least the dialog is showing now...
Good luck,
Josh
-- modified at 21:05 Monday 24th April, 2006
|
|
|
|
|
Hey Josh, thanks a lot.
I've just tried your code and it works just like you said, as long as I remove the
[Editor("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
that I had in my code (taken from the DataGridView metadata). If not, the error persists.
At least with your suggestion the Columns can be edited in Design time. It's weird what's happening, maybe it's a bug in the IDE, I don't know. But I need this to work. Hopefully somebody will come out with a final solution, meanwhile you made my day man. Thank you a lot.
Hey MS guys overthere! Any idea about this?
Thanks Josh.
F.
|
|
|
|
|
Oh Man! This is FRUSTRATING!!!!
My smile was gone with a wink of my eye!!!
Damn it!
Your suggestion works since it makes the Edit Columns dialog appears, but, NOTHING is saved, any changes made to the columns (e.g. Header text) is gone as soon as you build the project!
Nothing is being persisted.
So, there's no point in having the dialog to make any change.
Gee, is really frustrating that something so simple is being such a pain in the "neck"!!!
What the heck is going on here? Please MS Guys, say something about this. It's quite simple and common what I'm trying to achieve here, and the thing is not working. Please.
Thanks Josh for all your help, I really appreciate it. Don't hesitate to go further if you have the time, this is war now
F.
|
|
|
|
|
Hi everybuddy,
I wana ask in your opinion how a 'Middleware' relates to or differs from an 'Application Server' such as ASP.NET?
Can we say one of these concepts contains the other? or they are different tools that help achieveing a similar goal?
Thank you,
- Den2Fly
---
"Art happens when you least expect it."
|
|
|
|
|
My understanding is that the term "Middleware" is some technology that sits between a front-end GUI and a back-end Database. Most notibly, this term used to be applied to MM Flash applications, where the swf would be the GUI, and a database used (eg/ MySQL or MSSQL) - as flash has no native ability to connect to a DB, "middleware" (eg/ asp, php, perl) was used to translate HTTP requests from flash to database calls & vice-versa.
ASP.NET can be used as this middleware, although these days flash has much more ability, such as Remoting which negates the use for such "middleware" solutions.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Yes, useful comment. Thank you for your note.
---
"Art happens when you least expect it."
|
|
|
|