Why SOMETIMES when i try to assign an object to null in immediate window i can't?

  • Thread starter Thread starter TS
  • Start date Start date
T

TS

I get this message in the window "cannot assign 'null' into 'xxxxx'". this
is an object and hence a reference type. Sometimes this isn't
permitted...why?

thanks
 
Hi TS,

Can you tell me what version of Visual Studio you are using, VS.net2003 or
VS2005? What type of project you are creating, winform, console or Asp.net?
Finally, what language you are using, C# or VB.net? These information will
be helpful for us to accurate identify the problem context. Thanks.

I have tried to use VS2005 with C# language to perform a test in a winform
project. My testing code snippet is listed below:

Form f = new Form();
private void button1_Click(object sender, EventArgs e)
{
}

I set a breakpoint in button1_Click method, once the breakpoint is hit, I
input "this.f=null" in the "Immediate window", I will get the following
result:

this.f=null
null

So, it seems that it works well on my side.

Can you provide a little sample project and detailed reproduce steps to
help me reproduce your problem? I look forward to your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
TS said:
any comments?

There was one from Jeffrey Tan of Microsoft, which was full of
pertinent questions. Please answer those. Most importantly, please
provide a short but complete program which demonstrates your problem.
 
TS a écrit :
any comments?

Hello,

Perhaps about Structure type, like a DateTime : you cannot assign null toa
DataTime object because it is a srtuct.

HTH.
 
Hi TS,

I am reviewing this issue thread. It seems Jeffery's reply is omitted. I am
not sure of whether this is a system error. So I pasted it again in the
following. Your further information is quite helpful for the issue
resolution. Thanks very much and look forward to your reply.

-----
From: (e-mail address removed) ("Jeffrey Tan[MSFT]")
Date: Fri, 29 Sep 2006 08:57:54 GMT
Subject: RE: Why SOMETIMES when i try to assign an object to null in
immediate window i can't?
Newsgroups: microsoft.public.dotnet.languages.csharp

Hi TS,

Can you tell me what version of Visual Studio you are using, VS.net2003 or
VS2005? What type of project you are creating, winform, console or Asp.net?
Finally, what language you are using, C# or VB.net? These information will
be helpful for us to accurate identify the problem context. Thanks.

I have tried to use VS2005 with C# language to perform a test in a winform
project. My testing code snippet is listed below:

Form f = new Form();
private void button1_Click(object sender, EventArgs e)
{
}

I set a breakpoint in button1_Click method, once the breakpoint is hit, I
input "this.f=null" in the "Immediate window", I will get the following
result:

this.f=null
null

So, it seems that it works well on my side.

Can you provide a little sample project and detailed reproduce steps to
help me reproduce your problem? I look forward to your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
-----



Sincerely,
Yanhong Huang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
i've been viewing posts thru outlook express and it never came over. I just
now see this post and Cyrille37 and Yan-Hong. That is aggrevating because
i've been checking this post every day.

thanks for informing me, i guess OE is quirky. (This has happened before).
i'll check out the other post from the website.
 
First off i'd like to say that I never got this post thru outlook express and
only just now see this post thru the website...

vs 2003, web app, C#

i'm also sorry to say that i have shutdown VS since my post so long ago, and
i cannot retrieve that line from the command window and don't recall which
object i was working with.

When i come across it again, i will make sure to get the code to simulate it
and post it. I do know that i have run across this more than a couple of
times in the last year at different spots.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top