14 Replies - 935 Views - Last Post: 06 August 2012 - 03:06 PM
#1
Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 04:48 AM
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 !!!
Replies To: Namespace and/or intellisense trouble in VS2010 !
#2
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 05:19 AM
This post has been edited by MrShoes: 06 August 2012 - 05:20 AM
#3
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 05:23 AM
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.
#4
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 06:27 AM
MrShoes, on 06 August 2012 - 05:19 AM, said:
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 ?
#5
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 06:43 AM
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.
#6
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 07:55 AM
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 - >

In VB - >

Thanks for all the responses and attempts to assist me MrShoes.
#7
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 08:00 AM
As suspected, this is not a problem with VS or XP. That is simply a difference between the 2 languages.
#8
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 09:47 AM
petkovic, on 06 August 2012 - 06:27 AM, said:
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?
#9
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 12:02 PM
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)
#10
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 12:14 PM
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
#11
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 12:31 PM
Skydiver, on 06 August 2012 - 07:14 PM, said:
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?
#12
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 12:34 PM
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#.
MrShoes, on 06 August 2012 - 12:31 PM, said:
Skydiver, on 06 August 2012 - 07:14 PM, said:
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.
#13
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 01:09 PM
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.
#14
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 01:32 PM
Quote
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.
#15
Re: Namespace and/or intellisense trouble in VS2010 !
Posted 06 August 2012 - 03:06 PM
petkovic, on 06 August 2012 - 01:09 PM, said:
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.)
|
|

New Topic/Question
Reply



MultiQuote






|