xsharp.eu • MySqlConnection open object reference not set to an instance of an object - Page 2
Page 2 of 3

MySqlConnection open object reference not set to an instance of an object

Posted: Tue Aug 11, 2020 2:25 pm
by ic2
Hello Robert,
robert wrote:Dick,
I suspect this is an exception inside the Open() code that is actually handled inside that code. So you can probably press Continue inside VS and see that the app continues without problems.

Maybe the error will disappear if you enable the 'Just my code' option in the debugger options ?
Wow, that's quick!

Yes sir, you are right again. I've located that debug option (I remember I have seen that before, probably it was unchecked again in VS 2019) and checking it the debugger continues as well, without issues.

Not sure if any programmer is interested in getting an incomprehensible exception from somewhere within a DLL which in the end still appears to work anyhow but hopefully your hint to change this settings saves me some hours in the future!

Dick

MySqlConnection open object reference not set to an instance of an object

Posted: Tue Aug 11, 2020 2:29 pm
by robert
ic2 wrote:Hello Robert,

Not sure if any programmer is interested in getting an incomprehensible exception from somewhere within a DLL which in the end still appears to work anyhow but hopefully your hint to change this settings saves me some hours in the future!

Dick
Well, sometimes I am interested in these errors. And if you then open the call stack you can probably navigate to the method where the exception occurred and was caught. Exceptions that are caught are sometimes related to other unexpected behavior that happens later.

Robert

MySqlConnection open object reference not set to an instance of an object

Posted: Tue Aug 11, 2020 4:23 pm
by ic2
Hello Robert,
robert wrote: Well, sometimes I am interested in these errors. And if you then open the call stack you can probably navigate to the method where the exception occurred and was caught. Exceptions that are caught are sometimes related to other unexpected behavior that happens later.
Robert
I can imagine that for you that but still it shouldn't be the default setting for VS.

Dick

MySqlConnection open object reference not set to an instance of an object

Posted: Wed Aug 12, 2020 10:41 am
by lumberjack
Hi Dick,
ic2 wrote: While it (now) all works without issues when running directly it gives this stupid error when using the VS debugger. I would say it's the opposite of a timing problem Terry suggests but your approach Terry seems to makes sense.
Now that you mention this. It is not VS, I find the same behaviour in XIDE when you step through PostgreSQL connections, seems the backend creates a time-out error.
I have found to rather create a breakpoint passed the complete opening/command creation and not to have a "DEBUG pause" during setting up of DB connections.

HTH,

MySqlConnection open object reference not set to an instance of an object

Posted: Wed Aug 12, 2020 3:43 pm
by Chris
HI Johan,

In XIDE, this is handled via Debug->Handled Exception->Break Never/Always. There's also an option to break in only specific handled exceptions, but I see this is not working correctly, will look into it.

MySqlConnection open object reference not set to an instance of an object

Posted: Wed Aug 12, 2020 10:16 pm
by lumberjack
Hi Chris,
Chris wrote:HI Johan,
In XIDE, this is handled via Debug->Handled Exception->Break Never/Always. There's also an option to break in only specific handled exceptions, but I see this is not working correctly, will look into it.
No worries, I know why my "DEBUG" sometimes don't work when stepping, it is just something to be aware of, hence it don't bother me.

MySqlConnection open object reference not set to an instance of an object

Posted: Thu Aug 13, 2020 9:51 am
by TerryB1
Hi Dick
What I am wondering: I've taken almost every opportunity to write how much I hate Visual Studio. I think when using VS 3/4 of my programming time is trying solve these kind of (non) issues. Could anybody tell me if I am doing something wrong to get hours consuming VS problems like this? Or is this something everyone considers normal in VS and am I the only one thinking that an exception like this does not make sense?

Exceptions like this do make sense (eventually). The fact is that the way a digital computer works is the same as it has always been. Even back to the valveelectro-mechanical devices of yester-year.
The difference today is simply that, because of a number of factors including increased reliability and speed, it has driven us all to be able to “see” things from a different perspective (if we want to).

The “vision” I have of computer operation – i.e. “What is happening when a computer application is actually running under user control” is quite clear in my mind. It is very easy to understand. It will be clear also to you. Why? Because it is based on what we all know and do in real life.
What is more difficult to do, in fact impossible in limited time/space available here, is to demonstrate a proof of what I say. I must ask you to simply accept that the veracity of analogies I make can be proved.
We live in a 3-dimensional world. Everything we do is constrained to being done in those 3 dimensions. To do anything takes time. Nothing gets done in zero time. We move around to do anything – go from place to place. Think of these “places” as buildings in a town, city or village – they are all different, equipped to do different things. But to get from one to another we move in any one of the 3 dimensions.
In our world, of course, gravity plays a part, but let’s imagine we’re in free space. We can then imagine our buildings to be “floating around” in that space.

Now let’s transpose that imaginary vision to any digital computer application.
Think of the buildings being classes.
There is really no limit to the images we can generate of all this, in our minds. All our classes have some sort of path between them – maybe see it as a number of balloons floating in the air, tethered to some point on the ground. Some of those paths can be direct, some down one tethering string and back up another.
So you may end up with a picture of children on the beach, on a fine summers day, flying balloons and larking about. An easy to see picture, with huge underlying complexity, should be building up in your mind.
Let’s add to the complexity of the vision – each building (or class, or balloon) can have different rooms, each reached via a 3-D vector from its neighbour. And so it goes on. The underlying complexity of the picture just grows, whereas the “picture” itself remains much the same.
So, Dick, my advice to you is try to envisage your applications as 3-Dimensional entities, rather than you may have been doing in the past as 2-D entities.
Hope that helps a bit. But of course the devil’s in the detail and that comes when trying to convert that aforesaid complex picture back into code. (An exercise for the reader!!??).
Terry

MySqlConnection open object reference not set to an instance of an object

Posted: Mon Aug 17, 2020 12:43 pm
by ic2
Hello Thierry,

I am not sure I follow you here. I would say that seeing my applications as 2D or 3D won't bring down the high number of nuisance moments I experience working with VS. :(

Dick

MySqlConnection open object reference not set to an instance of an object

Posted: Mon Aug 17, 2020 2:50 pm
by TerryB1
Hi Dick

>>I am not sure I follow you here. I would say that seeing my applications as 2D or 3D won't
>>bring down the high number of nuisance moments I experience working with VS.

You're right it probably wouldn’t help to bring down what you describe as “nuisance moments”. But it may help to understand why you get them – and why, I think they are inevitable. In fact, I’m pretty sure they are inevitable.
My point is that C# as a programming language targets a far broader range of application types than any single language type derived from it. This obviously has implications for Visual Studio which tries to encompass everything you can think of.
I would not expect anyone to visualise things in exactly the same way as I do – that would be silly since nature forces us all to think for ourselves in our own way. The only commonality is the 3-Dimensional nature of everything. Once we think that way it brings about great simplification in the way we may tackle programming tasks. What we do in normal life has direct read-across to anything we may wish to “program”. If we can’t think of how to do something ourselves (albeit at snail’s pace) – we won’t be able to do it electronically, and vice-versa. We can think things through, without ever going near the complexity of coding. Furthermore 3-Dimensions is the highest number we’ll ever need to think about. (I can’t be sure, but I strongly suspect, that MS engineering teams think the way I describe – the Roslyn compiler talks of visiting / re-visiting classes just like we might visit/re-visit friends/ shops etc in real life. And, of course, time is the elephant in the room. Everything takes time to do).
Sorry if I’m rambling on. I can quite see how you may wish to see things from a 2-D point of view. If that works for you, then why change?
It is only my personal opinion that if we are to fully embrace and run with what technology currently offers, the easiest way is to make a mental jump to 3-D thinking.
Terry

MySqlConnection open object reference not set to an instance of an object

Posted: Mon Aug 17, 2020 3:21 pm
by ic2
Hello Terry,
Terry wrote:
You're right it probably wouldn’t help to bring down what you describe as “nuisance moments”. But it may help to understand why you get them – and why, I think they are inevitable. In fact, I’m pretty sure they are inevitable.
I am afraid I still don't know if I see things 2D or 3D and how to change that, should I wish so, but one thing I do agree: VS being a nuisance will be inevitable. It has been since the first version I ever installed (VS 2005) and although it has slightly improved in 15 years, I have to admit that, it is still a nuisance.

Dick