473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2189
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rc | last post by:
is there anyway of creating a class so that when it is used as the object directly it does the toSting implementation ie public class recordID private mid as string public overloads function...
2
by: qazmlp | last post by:
I have a class containing 5-6 member data. I want to provide a toString() method as a part of this class to help the users to do tracing. const std::string& toString() { std::string objectData...
1
by: Bakunin | last post by:
Hi, I may be doing something dumb but.......I have been using the data access ent lib to do the HOL's. All is well. However I now want to add the data access functionality to my BTS2004 project,...
101
by: Sean | last post by:
Book I am reading says that Cstr() is best method for efficency and safety however it doesnt compare that method of the .ToString() method. Which is best. Thanks
7
by: axkixx | last post by:
For whatever reason, I keep getting error of int.ToString() not existing. Why not? Has anyone encountered this problem before?
31
by: Zytan | last post by:
Everything (er, every class) in C# has ToString() which is conveniently automatically invoked when using it in Debug.WriteLine() or in a string concatenation, etc. I made a struct, and I want to...
19
by: Angus | last post by:
I have a socket class CTestClientSocket which I am using to simulate load testing. I create multiple instances of the client like this: for (int i = 0; i < 5; i++) { CTestClientSocket* pTemp...
11
by: etam | last post by:
Hi, why I can not override it? This line: virtual String^ ToString() override = Object::ToString; produces this error: cannot override base class method 'System::Object::ToString'. Why is...
19
by: Michael C | last post by:
If we have something like this object x = null; MessageBox.Show(x.ToString()) we get an error. That kindof makes sense but there is no reason the behaviour couldn't be to return an empty...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.