469,625 Members | 928 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

ToString() does not exist ... anywhere !

In .NET v1.1.4322 , in a VS.NET application , has anyone ever run into the
bizarre situation where at runtime .NET believes that the ToString() method
does not exist ...

Sometimes this problem will show up as a runtime exceptions, sometimes this
problem will only be clear via QuickWatch in Debug mode

But the error message is always identical :

"error: '{object name}.ToString' does not exist:"

It could be

System.Data.SqlConnection.SqlClient.State.ToString ()

or it could be

Application["key name"].ToString()

or a variety of other uses of the ToString() method ...

I've tried rebuilding , restarting the machine ... but the problem
continues.

This is the strangest behavior I have ever encountered

Jun 15 '06 #1
25 2026
Nope, can't say I have experienced this or ever heard of it even.

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uX**************@TK2MSFTNGP04.phx.gbl...
In .NET v1.1.4322 , in a VS.NET application , has anyone ever run into the
bizarre situation where at runtime .NET believes that the ToString()
method does not exist ...

Sometimes this problem will show up as a runtime exceptions, sometimes
this problem will only be clear via QuickWatch in Debug mode

But the error message is always identical :

"error: '{object name}.ToString' does not exist:"

It could be

System.Data.SqlConnection.SqlClient.State.ToString ()

or it could be

Application["key name"].ToString()

or a variety of other uses of the ToString() method ...

I've tried rebuilding , restarting the machine ... but the problem
continues.

This is the strangest behavior I have ever encountered

Jun 15 '06 #2
"John A Grandy" <johnagrandy-at-yahoo-dot-com> ha scritto nel messaggio

"error: '{object name}.ToString' does not exist:"

It could be

System.Data.SqlConnection.SqlClient.State.ToString ()

or it could be

Application["key name"].ToString()

or a variety of other uses of the ToString() method ...

I've tried rebuilding , restarting the machine ... but the problem
continues.


Can't you debug this?
Jun 15 '06 #3
"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uX**************@TK2MSFTNGP04.phx.gbl...
<snip>
But the error message is always identical :

"error: '{object name}.ToString' does not exist:"


Quick checklist
Typo?
Did you remember the parens?

Bill
Jun 16 '06 #4
Well, neither of the 2 lines you are showing look valid to me; the first has
the namespace knackered, and doesn't seem to involve an instance; the second
(assuming System.Windows.Forms.Application) simply doesn't have a static
indexer.

QuickWatch will allow these as lines, but they will report error - simply
because they don't exist; I'd be more interested in the runtime exceptions,
as I don't think that code can compile.

Are you sure the problem isn't the code? Perhaps calling .ToString() on some
null objects? If you can get as far as runtime, then (assuming it isn't
reflection) it knows it exists. Have you overridden the ToString() method
and screwed it up, perhaps?

Marc
Jun 16 '06 #5
Ok, this is a production project that was working fine. It somehow
"entered" a state where somehow .NET is reporting that the .ToString()
method does not exist on various classes.

ToString() is not overriden anywhere in the project.

There was a typo: I meant

System.Data.SqlClient.SqlConnection con = new
System.Data.SqlClient.SqlConnection();
con.State.ToString();

QuickWatch on con.State.ToString() gives the error "error: '{object
name}.ToString' does not exist:"

Also, this is an ASP.NET app , so the intrinsic Application object is an
instance of the HttpApplicationState class

QuickWatch can be performed on Application[{key-name}] with no problem.

But QuickWatch on Application[{key-name}].ToString() gives the errror
"error: '{object name}.ToString' does not exist:"

"Marc Gravell" <ma**********@gmail.com> wrote in message
news:u$**************@TK2MSFTNGP05.phx.gbl...
Well, neither of the 2 lines you are showing look valid to me; the first
has the namespace knackered, and doesn't seem to involve an instance; the
second (assuming System.Windows.Forms.Application) simply doesn't have a
static indexer.

QuickWatch will allow these as lines, but they will report error - simply
because they don't exist; I'd be more interested in the runtime
exceptions, as I don't think that code can compile.

Are you sure the problem isn't the code? Perhaps calling .ToString() on
some null objects? If you can get as far as runtime, then (assuming it
isn't reflection) it knows it exists. Have you overridden the ToString()
method and screwed it up, perhaps?

Marc

Jun 19 '06 #6
You have to over ride ToString(). It is completely virtual. Hope that
helps.
Jun 19 '06 #7
I've never had to override ToString() before ... ever. I've seen the source
for dozens of high quality projects, and none of them includes overrides of
intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.
"poojo hackma" <poojo.com/mail> wrote in message
news:e9**************@TK2MSFTNGP04.phx.gbl...
You have to over ride ToString(). It is completely virtual. Hope that
helps.

Jun 19 '06 #8
> I've never had to override ToString() before ... ever. I've seen the
source for dozens of high quality projects, and none of them includes
overrides of intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.


I'm not 100%, but I think overriding ToString() started with VS 2005. Not
sure why some other things still work with ToString(); maybe they inherit
something else that has a built in version, but that's just a guess.
Jun 19 '06 #9
I'm on VS03 with .NET 1.1

"poojo hackma" <poojo.com/mail> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
I've never had to override ToString() before ... ever. I've seen the
source for dozens of high quality projects, and none of them includes
overrides of intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.


I'm not 100%, but I think overriding ToString() started with VS 2005. Not
sure why some other things still work with ToString(); maybe they inherit
something else that has a built in version, but that's just a guess.

Jun 19 '06 #10
John A Grandy wrote:
I've never had to override ToString() before ... ever. I've seen the source
for dozens of high quality projects, and none of them includes overrides of
intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.


Which exceptions? (type, message, stacktrace, code snippets please!)

QuickWatch sometimes does silly things. But it would be interesting to
see these exceptions and the code that generates them.

Max
Jun 19 '06 #11
Well, as I mentioned above, it's things like :

using System.Data.SqlClient;

SqlConnection sqlConnection = new
SqlConnection("server=SERVER1;database=DB1;TRUSTED _CONNECTION=true");
sqlConnection.Open();
if (sqlConnection.State.ToString() = "open")
{
....
....
}

If I QuickWatch over sqlConnection.State.ToString() I receive

"error: '{object name}.ToString' does not exist:"

"Markus Stoeger" <sp******@gmx.at> wrote in message
news:eB****************@TK2MSFTNGP05.phx.gbl...
John A Grandy wrote:
I've never had to override ToString() before ... ever. I've seen the
source for dozens of high quality projects, and none of them includes
overrides of intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.


Which exceptions? (type, message, stacktrace, code snippets please!)

QuickWatch sometimes does silly things. But it would be interesting to see
these exceptions and the code that generates them.

Max

Jun 19 '06 #12
Is there any particular reason not to use enumeration?

if(sqlConnection.State == ConnectionState.Open)
{
....
}

John A Grandy wrote:
Well, as I mentioned above, it's things like :

using System.Data.SqlClient;

SqlConnection sqlConnection = new
SqlConnection("server=SERVER1;database=DB1;TRUSTED _CONNECTION=true");
sqlConnection.Open();
if (sqlConnection.State.ToString() = "open")
{
...
...
}

If I QuickWatch over sqlConnection.State.ToString() I receive

"error: '{object name}.ToString' does not exist:"

"Markus Stoeger" <sp******@gmx.at> wrote in message
news:eB****************@TK2MSFTNGP05.phx.gbl...
John A Grandy wrote:
I've never had to override ToString() before ... ever. I've seen the
source for dozens of high quality projects, and none of them includes
overrides of intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.

Which exceptions? (type, message, stacktrace, code snippets please!)

QuickWatch sometimes does silly things. But it would be interesting to see
these exceptions and the code that generates them.

Max


Jun 20 '06 #13
This isn't a code-design exercise. This is a huge project written by
someone else. They already used .ToString() in thousands of places,
thousands of contexts. Somehow, ToString has stopped being recognized.

I've tried de-installing, re-installing .NET Framework 1.1.4322 , to no
avail.
"Sericinus hunter" <se*****@flash.net> wrote in message
news:CG*******************@newssvr11.news.prodigy. com...
Is there any particular reason not to use enumeration?

if(sqlConnection.State == ConnectionState.Open)
{
...
}

John A Grandy wrote:
Well, as I mentioned above, it's things like :

using System.Data.SqlClient;

SqlConnection sqlConnection = new
SqlConnection("server=SERVER1;database=DB1;TRUSTED _CONNECTION=true");
sqlConnection.Open();
if (sqlConnection.State.ToString() = "open")
{
...
...
}

If I QuickWatch over sqlConnection.State.ToString() I receive

"error: '{object name}.ToString' does not exist:"

"Markus Stoeger" <sp******@gmx.at> wrote in message
news:eB****************@TK2MSFTNGP05.phx.gbl...
John A Grandy wrote:
I've never had to override ToString() before ... ever. I've seen the
source for dozens of high quality projects, and none of them includes
overrides of intrinsic ToString() methods on .NET framework classes.

Project was in a working state before -- it never threw any of these
exceptions.
Which exceptions? (type, message, stacktrace, code snippets please!)

QuickWatch sometimes does silly things. But it would be interesting to
see these exceptions and the code that generates them.

Max


Jun 20 '06 #14
John A Grandy wrote:
If I QuickWatch over sqlConnection.State.ToString() I receive

"error: '{object name}.ToString' does not exist:"


You can't use the Watch window on methods. It only works for fields and
properties (at least in VS2003, dunno about VS2005).

If you get real (runtime) exceptions, please post their type, message
and stacktrace.

Max
Jun 20 '06 #15


Hi, Just wondering if you found the answer to the .Tostring problem,
Currently i am having the same problem.
If i try the same code in vb instead of c# it works fine. Appear to be
affecting c# only.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 4 '07 #16
D W

I'd love to see an answer posted for this issue too. I'm having the
exact same problem in VS2003.

Here's the line:

cmd.Parameters.Add("@DestDB", newCompany.ToString() + RequestYear);

It's a very simple concat that's been working since before I started
with this company. In fact, it was working about an hour ago. The
project compiles, and I even get a "ToString" option from Intellisense,
but I still get the not recognized error at runtime.

"newCompany" is an enum type that has a verifiable value before trying
to execute this line. "RequestYear" is a string representing a 4 digit
year.

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '07 #17
On Sep 28, 3:26 pm, D W <gusar...@hotmail.comwrote:
I'd love to see an answer posted for this issue too. I'm having the
exact same problem in VS2003.

Here's the line:

cmd.Parameters.Add("@DestDB", newCompany.ToString() + RequestYear);

It's a very simple concat that's been working since before I started
with this company. In fact, it was working about an hour ago. The
project compiles, and I even get a "ToString" option from Intellisense,
but I still get the not recognized error at runtime.

"newCompany" is an enum type that has a verifiable value before trying
to execute this line. "RequestYear" is a string representing a 4 digit
year.
What error do you get at runtime *not* in the debugger? I suggest we
ignore the debugger for the moment, as the VS2003 debugger in
particular had some issues.

Jon

Sep 28 '07 #18
D W <gu******@hotmail.comwrote:
I replied to this a while ago, but don't see it here now.

To reiterate:

I was having other runtime issues not involving this one, so I can't say
that it was strictly a debugger issue...though I believe that it was.

Here's what I did instead that worked:

string Company = System.Convert.ToString(newCompany);
string Year = System.Convert.ToString(RequestYear);

cmd.Parameters.Add("@DestDB", System.String.Concat(Company + Year));
There's really no reason that should work but the "normal" way
wouldn't. I strongly suspect it was just a debugger issue.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 28 '07 #19
D W

I replied to this a while ago, but don't see it here now.

To reiterate:

I was having other runtime issues not involving this one, so I can't say
that it was strictly a debugger issue...though I believe that it was.

Here's what I did instead that worked:

string Company = System.Convert.ToString(newCompany);
string Year = System.Convert.ToString(RequestYear);

cmd.Parameters.Add("@DestDB", System.String.Concat(Company + Year));
*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '07 #20
D W
Sorry about that.

I never specified that I wanted to email you. Hopefully, you don't get
this one too.

I didn't see anything in the FAQ about it either. Did I miss something?


*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '07 #21
D W
Sorry about that.

I never specified that I wanted to email you. Hopefully, you don't get
this one too.

I didn't see anything in the FAQ about it either. Did I miss something?


*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '07 #22
D W <gu******@hotmail.comwrote:
Sorry about that.

I never specified that I wanted to email you. Hopefully, you don't get
this one too.
Um, these aren't emails, but newsgroup posts.
I didn't see anything in the FAQ about it either. Did I miss something?
Anything in the FAQ about what in particular?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 28 '07 #23
D W saw your signature block and thought it was part of your answer.
Actually, both are great and keep it up!

"Jon Skeet [C# MVP]" wrote:
D W <gu******@hotmail.comwrote:
Sorry about that.

I never specified that I wanted to email you. Hopefully, you don't get
this one too.

Um, these aren't emails, but newsgroup posts.
I didn't see anything in the FAQ about it either. Did I miss something?

Anything in the FAQ about what in particular?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 29 '07 #24
D W
Funny. I looked for that signature in his previous posts, but it didn't
appear...so I thought I was being reprimanded for something I didn't do.
This thread appears in a few places, and I didn't know if the site I was
using was sending emails I didn't know about.

Oh well, thanks for the input anyway.

*** Sent via Developersdex http://www.developersdex.com ***
Oct 1 '07 #25
On Oct 1, 2:45 pm, D W <gusar...@hotmail.comwrote:
Funny. I looked for that signature in his previous posts, but it didn't
appear...so I thought I was being reprimanded for something I didn't do.
This thread appears in a few places, and I didn't know if the site I was
using was sending emails I didn't know about.
Ah, no - if I'm posting via Google Groups (as I am now) I don't get a
sig. When I post using Gravity, from home, I use that as a standard
signature.

No reprimand intended :)

Jon

Oct 1 '07 #26

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by rc | last post: by
2 posts views Thread by qazmlp | last post: by
101 posts views Thread by Sean | last post: by
7 posts views Thread by axkixx | last post: by
19 posts views Thread by Angus | last post: by
11 posts views Thread by etam | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.