14 Replies - 2645 Views - Last Post: 06 August 2012 - 03:06 PM Rate Topic: -----

#1 petkovic  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 29-August 11

Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 04:48 AM

More than two weeks has a problem with VS 2010 Pro (ver : 10.0.40219.1 SP1Rel) and .NET Framework (ver : 4.0.30319 SP1Rel).
On my computer I have installed WinXP SP3.

The problem is going to win and asp.net applications.

When you create a win application, the module code entered default namespaces such as
System.Data.

When in some method I try to type SqlClient, this namespace is not offered Intellisense .
As it does not exist. Only when I specify the full path System.Data.SqlClient then becomes visible!

When I try something like :

SqlClient.SqlDataAdapter da = new SqlClient.SqlDataAdapter();

VS shows me an error - > "The type or namespace name 'SqlClient' could not be found (are you missing a using directive or an assembly reference?)..."

I do not know whether the problem with the namespace or the Intellisense.

Many people on the internet complain of this problem (namespace trouble in VS2010), it seems that this is a serious bug.

In VB.Net everything is working properly, Intelisenše shows SqlClient, when I import the namespace
Import System.Data and type SqlClient .

What I tried to do everything, and nothing gave the results:

1) I changed the Target Framework 3.5 with Net Framework Client Profile to Net Framework 4.0 and rebuild app.
it seems that this is a bug per cent when I create an application
VS2010 by default sets the target on the Net Framwork 3.5 Client Profile.

2) I created Empty project and manually added reference - System.Data. Nothing has changed !

3) I set the VS2010 loading namespaces (References Path) from the first location of C: \ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319. Nothing has changed !
4 ) I Create new project and set the VS2010 loading namespaces (References Path) from second location C: \ Program Files \ Reference Assemblies \ Microsoft \ Framework \. NETFramework \ v4.0. Nothing has changed.

Why System.Data.dll has different size but same file version , from these two locations?

5) I did a complete reinstall vs2010. Nothing has changed !
6) Finally , I installed vs2010 SP1 (service pack). Nothing has changed !

Does anyone know what the problem is and how it can be solved ?

forward to thank everyone who offers an answer !!!

Is This A Good Question/Topic? 0
  • +

Replies To: Namespace and/or intellisense trouble in VS2010 !

#2 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 05:19 AM

I'm not sure I FULLY understand your problem, but System.Data.SqlClient is a different namespace from System.Data. Do you have a using System.Data.SqlClient; line in the code file?

This post has been edited by MrShoes: 06 August 2012 - 05:20 AM

Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,918
  • Joined: 02-June 10

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 05:23 AM

Personally I would format your PC and start fresh. don't use pirated OS or installers. Do update everything.
It doesn't help that you are using a long dead OS. Those of us that aren't a decade out of date don't seem to have this issue. You might consider Windows 7 & 8.
Was This Post Helpful? 0
  • +
  • -

#4 petkovic  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 29-August 11

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 06:27 AM

View PostMrShoes, on 06 August 2012 - 05:19 AM, said:

I'm not sure I FULLY understand your problem, but System.Data.SqlClient is a different namespace from System.Data. Do you have a using System.Data.SqlClient; line in the code file?

MrShoes

In Solution Explorer, open the References folder, double click
on System.Data - will open the Object Browser. Expand System.Data and System.Data.SqlClient double click.

There is a message System.Data.SqlClient namespace
Member of System.Data.

I have no line of code using System.Data.SqlClient;
but only using System.Data;

Since part of the SqlClient namespace System.Data, I expect to appear in intellisense
after I import a reference to System.Data.

In VB.Net work properly .

Are you in the intellisense SqlClient appears only when you have a line
System.Data?

Please MrShoes

Create win application in VB.Net and add the namespace ->

Import System.Data

and in Form_Load() try type SqlClient - I't available in Intellisense .
Example in VB :
-------------------------------------------
Imports System.Data

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SqlClient....
End Sub
End Class
-----------------------------------------

So why are not acting in C # as well as in VB.Net ?
Was This Post Helpful? 0
  • +
  • -

#5 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 06:43 AM

My understanding is that it is part of the same library, but it's nevertheless a different namespace. I'm using VS2010 Pro and have to specify I'm using that namespace, or suffer the consequence of using the fully qualified name. Likewise, at home, where I use 2010 Express.

I don't know VB well enough to tell you why it's different, but it's a different language, so I wouldn't necessarily expect them to behave the same. That doesn't mean it's not working in C#. It just behaves differently. Kind of like "Breathing is easy on Earth, but on Mars I have to bring my own oxygen".

Note also this is not a problem with IntelliSense.

Try adding the line I mentioned and see what happens.
Was This Post Helpful? 0
  • +
  • -

#6 petkovic  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 29-August 11

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 07:55 AM

I know that when I enter a line using Syste.Data.SqlClient
everything is working properly ,
but I still believe that when I import
namespace System.Data should we direct the available namespace
SqlClient (See picture examples).

In CS - >
Attached Image


In VB - >
Attached Image

Thanks for all the responses and attempts to assist me MrShoes.
Was This Post Helpful? 0
  • +
  • -

#7 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 08:00 AM

OK. What you're showing me from VB is that you can use a namespace that is derived from a namespace. In C#, you have to use the using keyword to add the namespace to the code file before you can use it in code without the fully qualified name. Note that the IntelliSense shown in the second image has {} after SqlClient - proof it's a namespace.

As suspected, this is not a problem with VS or XP. That is simply a difference between the 2 languages.
Was This Post Helpful? 1
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,280
  • Joined: 05-May 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 09:47 AM

View Postpetkovic, on 06 August 2012 - 06:27 AM, said:

I have no line of code using System.Data.SqlClient;
but only using System.Data;

Since part of the SqlClient namespace System.Data, I expect to appear in intellisense
after I import a reference to System.Data.


That is the incorrect expectation. It's like expecting MessageBox which is in System.Windows.Forms to be available to you just because you put in a line saying "using System.Windows;". Do you have the same expectation that if you put in "using System;" that you'll get System.Net.Mail automatically as well?
Was This Post Helpful? 0
  • +
  • -

#9 petkovic  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 29-August 11

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 12:02 PM

Suppose that a namespace (parent - namespace A) contains another namespace (child - namespace B)

example of nesting namespaces

namespace A
{
public class SomeClassA{...}

namespace B
{
public class SomeClassB{...}
}
}


If we can not access the namespaceB throw its parent (namespace A),
what is the purpose hierarchical structure of namespace?

Why then declare namespaces within one another?

Namespaces are by nature public!

It seems to me that in the VB namespaces done with more logic and the expectations of developers.

it is very important to me, you confirm that this is not a bug (as I thought) but that is normal behavior in CS!

As for your question, sir Skjdiver, my expectations are shown in Figure - >

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#10 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,280
  • Joined: 05-May 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 12:14 PM

If that is your expectation, why not just have two lines at the top of the file?
using System;
using Microsoft;



After that point all the other namespaces below those two should be offered to you, right? Or do your expectations only apply after it gets past the second level of nesting?

This post has been edited by Skydiver: 06 August 2012 - 12:15 PM

Was This Post Helpful? 1
  • +
  • -

#11 MrShoes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 313
  • View blog
  • Posts: 490
  • Joined: 13-June 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 12:31 PM

View PostSkydiver, on 06 August 2012 - 07:14 PM, said:

If that is your expectation, why not just have two lines at the top of the file?
using System;
using Microsoft;



After that point all the other namespaces below those two should be offered to you, right? Or do your expectations only apply after it gets past the second level of nesting?


Why even specify any using statements? Why not just have all namespaces available? Why not a "write my code" button?
Was This Post Helpful? 1
  • +
  • -

#12 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,280
  • Joined: 05-May 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 12:34 PM

Namespaces are meant to partition scope and prevent name conflicts. For example, consider how many ListBox classes there are:
System.Windows.Controls.ListBox
System.Windows.Forms.ListBox
System.Web.UI.WebControls.ListBox
Microsoft.Office.Tools.Excel.Controls.ListBox
Microsoft.Office.Tools.Word.Controls.ListBox

Without namespaces, each one author of a component or library would have to research the entire world and come up with a unique name for their type.

As for nesting namespaces, it lets an author not only prevent name conflicts, but also partition classes into intended purposes, just like nesting classes. Additionally, the application of the access is consistent. This applies the principle of least surprise.

For example:
namespace Foo
{
    namespace Bar
    {
        public class X { }
        private class Y { }
    }
}


Behaves exactly like:
public class Foo
{
    public class Bar
    {
        public class X { }
        private class Y { }
    }
}


when you try to access classes X and Y.

Perhaps the principle of least surprise didn't work for you when you moved from VB to C#, but it works for somebody moving from C++ or Java to C#.

View PostMrShoes, on 06 August 2012 - 12:31 PM, said:

View PostSkydiver, on 06 August 2012 - 07:14 PM, said:

If that is your expectation, why not just have two lines at the top of the file?
using System;
using Microsoft;



After that point all the other namespaces below those two should be offered to you, right? Or do your expectations only apply after it gets past the second level of nesting?


Why even specify any using statements? Why not just have all namespaces available? Why not a "write my code" button?


He probably hasn't tried Resharper's Intellisense++, yet. :lol:
Was This Post Helpful? 0
  • +
  • -

#13 petkovic  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 29-August 11

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 01:09 PM

My dear C # developers.

I did not want to enter my confusion among you or make you upset.

Mister , Skydiver I know very well what the namespaces.I have ten years experience in VB.Net and now I try to switch to C #.
I did not expect it to C # so it acts when it comes to namespaces?

For all the praise the fact that the CS compiler has so much power that I recognize the whole structure of
anonymous methods, and that is so simplified by using the lambda expression as a replacement.

On the other hand, the CS compiler can not recognize and allow access to nested
namespaces through their container namespaces, if we just import a reference to the container namespace!

I do not know about you, but for me it is very disappointing.

I thank everyone who tried to help me.
I have no more need for further answers.
Thank you.
Was This Post Helpful? 0
  • +
  • -

#14 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 01:32 PM

Quote

I do not know about you, but for me it is very disappointing.


No, I don't find this disappointing at all, in fact quite the opposite. For me this is more of a feature than a hindrance.
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,280
  • Joined: 05-May 12

Re: Namespace and/or intellisense trouble in VS2010 !

Posted 06 August 2012 - 03:06 PM

View Postpetkovic, on 06 August 2012 - 01:09 PM, said:

On the other hand, the CS compiler can not recognize and allow access to nested
namespaces through their container namespaces, if we just import a reference to the container namespace!

Intellisense does not come from the compiler. It comes from the text editor. Believe you me, that I had wished that Intellisense came with the compiler because I was using a text editor that a few versions back was just completely confused by .NET Framework symbols and which were available in what context. It was acting more like VB.NET was acting for you. It was offering things that I didn't have access to. Since I was using the .NET C# compiler, the same compiler that VS2010 uses, it would have been nice if I got the same level of "intelligence" of what symbols were available to me within a given scope. But, alas, as I said, it's a function of the text editor and not the compiler. (I only stuck with the other text editor because unlike VS2010, it wouldn't crash or hang randomly. Fortunately, the current version the text editor is much better in offering symbols.)
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1