PC Review


Reply
Thread Tools Rate Thread

when I add a new class to the project, all the other goes wrong.

 
 
mathphoenix
Guest
Posts: n/a
 
      29th Apr 2009
I have a csharp project develop with vs2008, it can pass build first,
when I add a new class to it, the other class in the project can't pass the
compiler check, I can't check the new class now, It seem that all go wrong.
anyone meet the trouble?

Another question, is that different the using direction inside or beside
the namespace ?

 
Reply With Quote
 
 
 
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      29th Apr 2009
Hi,

You really need to give us more information than this, especially the exact
errors you get. If the project can't pass the compiler check there should be
compiler errors/warnings.

The 'using' keyword serves two purposes.

using System.IO;

namespace MyNamespace
{
// You can here type File instead of the full System.IO.File
}

Inside a method it serves the IDisposable interface and will automatically
call Dispose

void MyMethod()
{
using(StreamWriter sw = new StreamWriter("C:\\MyFile.txt"))
{
sw.WriteLine("Hello World");
}
}

when the using block ends it will call sw.Dispose(), which in turn will
Flush and Close the StreamWriter as well.

--
Happy Coding!
Morten Wennevik [C# MVP]


"mathphoenix" wrote:

> I have a csharp project develop with vs2008, it can pass build first,
> when I add a new class to it, the other class in the project can't pass the
> compiler check, I can't check the new class now, It seem that all go wrong.
> anyone meet the trouble?
>
> Another question, is that different the using direction inside or beside
> the namespace ?
>

 
Reply With Quote
 
Pavel Minaev
Guest
Posts: n/a
 
      29th Apr 2009
On Apr 28, 8:38*pm, "mathphoenix" <mathphoe...@live.com> wrote:
> * *Another question, is that different the using direction inside or beside
> the namespace ?


If you mean the difference between:

using System;
namespace Foo {
...
}

and

namespace Foo {
using System;
...
}

then yes, there is a subtle difference there for the single-namespace-
in-a-file case, when it comes to dealing with classes in the global
namespace. I'll just illustrate with code:

// Outside of any namespace
class Foo { ... }
namespace Bar { class Foo { ... } }

using Bar;
namespace Test1 {
using F = Foo; // Foo here is global::Foo
}

namespace Test2 {
using Bar;
using F = Foo; // Foo here is Bar.Foo
}

Basically, the way it works is this: it looks for the identifier in
scopes starting from the innermost one and going outside; and, for
each scope, it _first_ looks for identifiers declared in that scope
(i.e. in the same namespace, for a namespace), and only then looks in
namespaces referenced by "using" directives within that scope.

In practice, since common coding style is to avoid out-of-namespace
declarations, this difference is hardly ever observed.

For the case of multiple namespaces in a file, the difference is more
pronounced, but should be fairly obvious.
 
Reply With Quote
 
mathphoenix
Guest
Posts: n/a
 
      29th Apr 2009
some more detail, I have use c# for many yeas, I understand the concept, I
think it may be bug of visual studio 2008?
I am doing some refractor of dotnetnuke(the edition 4.09) for my own
purpose.
one file which can pass check before like this:

namespace DotNetNuke.Services.Vendors
{
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Data;

using System;
using System.Collections;
using System.Runtime.CompilerServices;

public class BannerController
{
public void AddBanner(BannerInfo objBannerInfo)
{
DataProvider.Instance().AddBanner(objBannerInfo.BannerName,
objBannerInfo.VendorId, objBannerInfo.ImageFile, objBannerInfo.URL,
objBannerInfo.Impressions, objBannerInfo.CPM, objBannerInfo.StartDate,
objBannerInfo.EndDate, objBannerInfo.CreatedByUser,
objBannerInfo.BannerTypeId, objBannerInfo.Description,
objBannerInfo.GroupName, objBannerInfo.Criteria, objBannerInfo.Width,
objBannerInfo.Height);
}

......
}
}


Now, i was told that error CS0234: “Utilities” is not exists in namespace
“DotNetNuke.DotNetNuke.Common”(miss some reference?) ,

In my opinion, no matter which file I add to this project, the error is
misleading, and should be a bug, or it's my fault?

The project's default namespace is DotNetNuke, and I think it's nothing
about the using directive , isn't it?

"mathphoenix" <(E-Mail Removed)> 写入消息
news:21AA3F68-D0C8-4C13-BB33-(E-Mail Removed)...
> I have a csharp project develop with vs2008, it can pass build first,
> when I add a new class to it, the other class in the project can't pass
> the compiler check, I can't check the new class now, It seem that all go
> wrong. anyone meet the trouble?
>
> Another question, is that different the using direction inside or beside
> the namespace ?


 
Reply With Quote
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      29th Apr 2009

I have seen cases where the error message is comletely irrelevant to the
actual error, as well as cases where it just simply says build failed with no
error messages or warnings at all (turned out it didn't like two vs instances
with a database project in each solution). It is apparantly unable to
understand Utilities, but the reason may not be so obvious. As you have put
it as a using directive the most likely cause would be that you are not
referencing the project/assembly containing the DotNetNuke.Common.Utilities
classes.

In your code, if you have at least one class with the namespace
DotNetNuke.Common.Utilities in a referenced project the code should compile.
There may be an error if you at the same time have a Utilities class in
DotNetNuke.Common but the error message should in that case indicate that
Utilities already exists.

I assume you do have a class with this namespace, so there may well be a
bug. Try removing the using directive referring to Utilities and instead use
the full class name for BannerInfo and/or DataProvider. If this works, try
deleting the namespace part from BannerInfo/DataProvider and see if Visual
Studio is able to figure out where these classes are defineed (ALT+F10 when
the cursor is on the class name).

As for using directives inside or outside the namespace. I don't think it
matters at all as long as they are outside the class scope.

If you are able to reproduce the error in a new solution you can submit a
bug report at the Microsoft Developer Division Feedback Center

https://connect.microsoft.com/VisualStudio
(You may need to sign in to be able to submit a bug)

If you rather want me to submit the bug, send me a project where this bug is
reproducable and I'll be happy to submit a bug report.

--
Happy Coding!
Morten Wennevik [C# MVP]


"mathphoenix" wrote:

> some more detail, I have use c# for many yeas, I understand the concept, I
> think it may be bug of visual studio 2008?
> I am doing some refractor of dotnetnuke(the edition 4.09) for my own
> purpose.
> one file which can pass check before like this:
>
> namespace DotNetNuke.Services.Vendors
> {
> using DotNetNuke.Common;
> using DotNetNuke.Common.Utilities;
> using DotNetNuke.Data;
>
> using System;
> using System.Collections;
> using System.Runtime.CompilerServices;
>
> public class BannerController
> {
> public void AddBanner(BannerInfo objBannerInfo)
> {
> DataProvider.Instance().AddBanner(objBannerInfo.BannerName,
> objBannerInfo.VendorId, objBannerInfo.ImageFile, objBannerInfo.URL,
> objBannerInfo.Impressions, objBannerInfo.CPM, objBannerInfo.StartDate,
> objBannerInfo.EndDate, objBannerInfo.CreatedByUser,
> objBannerInfo.BannerTypeId, objBannerInfo.Description,
> objBannerInfo.GroupName, objBannerInfo.Criteria, objBannerInfo.Width,
> objBannerInfo.Height);
> }
>
> .....
> }
> }
>
>
> Now, i was told that error CS0234: “Utilities” is not exists in namespace
> “DotNetNuke.DotNetNuke.Common”(miss some reference?) ,
>
> In my opinion, no matter which file I add to this project, the error is
> misleading, and should be a bug, or it's my fault?
>
> The project's default namespace is DotNetNuke, and I think it's nothing
> about the using directive , isn't it?
>
> "mathphoenix" <(E-Mail Removed)> 写入消息
> news:21AA3F68-D0C8-4C13-BB33-(E-Mail Removed)...
> > I have a csharp project develop with vs2008, it can pass build first,
> > when I add a new class to it, the other class in the project can't pass
> > the compiler check, I can't check the new class now, It seem that all go
> > wrong. anyone meet the trouble?
> >
> > Another question, is that different the using direction inside or beside
> > the namespace ?

>

 
Reply With Quote
 
Jesse Houwing
Guest
Posts: n/a
 
      29th Apr 2009
Hello Morten Wennevik [C# MVP],

One other thing that comes to mind... Are you by any chance adding a file
called utilities.cs to the project? Or some other named class that corresponds
either with a namespace or a class elsewhere in your project?

Jesse

> I have seen cases where the error message is comletely irrelevant to
> the actual error, as well as cases where it just simply says build
> failed with no error messages or warnings at all (turned out it didn't
> like two vs instances with a database project in each solution). It
> is apparantly unable to understand Utilities, but the reason may not
> be so obvious. As you have put it as a using directive the most
> likely cause would be that you are not referencing the
> project/assembly containing the DotNetNuke.Common.Utilities classes.
>
> In your code, if you have at least one class with the namespace
> DotNetNuke.Common.Utilities in a referenced project the code should
> compile. There may be an error if you at the same time have a
> Utilities class in DotNetNuke.Common but the error message should in
> that case indicate that Utilities already exists.
>
> I assume you do have a class with this namespace, so there may well be
> a bug. Try removing the using directive referring to Utilities and
> instead use the full class name for BannerInfo and/or DataProvider.
> If this works, try deleting the namespace part from
> BannerInfo/DataProvider and see if Visual Studio is able to figure out
> where these classes are defineed (ALT+F10 when the cursor is on the
> class name).
>
> As for using directives inside or outside the namespace. I don't
> think it matters at all as long as they are outside the class scope.
>
> If you are able to reproduce the error in a new solution you can
> submit a bug report at the Microsoft Developer Division Feedback
> Center
>
> https://connect.microsoft.com/VisualStudio
> (You may need to sign in to be able to submit a bug)
> If you rather want me to submit the bug, send me a project where this
> bug is reproducable and I'll be happy to submit a bug report.
>
> "mathphoenix" wrote:
>
>> some more detail, I have use c# for many yeas, I understand the
>> concept, I
>> think it may be bug of visual studio 2008?
>> I am doing some refractor of dotnetnuke(the edition 4.09) for my own
>> purpose.
>> one file which can pass check before like this:
>> namespace DotNetNuke.Services.Vendors
>> {
>> using DotNetNuke.Common;
>> using DotNetNuke.Common.Utilities;
>> using DotNetNuke.Data;
>> using System;
>> using System.Collections;
>> using System.Runtime.CompilerServices;
>> public class BannerController
>> {
>> public void AddBanner(BannerInfo objBannerInfo)
>> {
>> DataProvider.Instance().AddBanner(objBannerInfo.BannerName,
>> objBannerInfo.VendorId, objBannerInfo.ImageFile, objBannerInfo.URL,
>> objBannerInfo.Impressions, objBannerInfo.CPM,
>> objBannerInfo.StartDate,
>> objBannerInfo.EndDate, objBannerInfo.CreatedByUser,
>> objBannerInfo.BannerTypeId, objBannerInfo.Description,
>> objBannerInfo.GroupName, objBannerInfo.Criteria, objBannerInfo.Width,
>> objBannerInfo.Height);
>> }
>> .....
>> }
>> }
>> Now, i was told that error CS0234: “Utilities” is not exists in
>> namespace “DotNetNuke.DotNetNuke.Common”(miss some reference?) ,
>>
>> In my opinion, no matter which file I add to this project, the error
>> is misleading, and should be a bug, or it's my fault?
>>
>> The project's default namespace is DotNetNuke, and I think it's
>> nothing about the using directive , isn't it?
>>
>> "mathphoenix" <(E-Mail Removed)> 写入消息
>> news:21AA3F68-D0C8-4C13-BB33-(E-Mail Removed)...
>>
>>> I have a csharp project develop with vs2008, it can pass build
>>> first, when I add a new class to it, the other class in the project
>>> can't pass the compiler check, I can't check the new class now, It
>>> seem that all go wrong. anyone meet the trouble?
>>>
>>> Another question, is that different the using direction inside or
>>> beside the namespace ?
>>>

--
Jesse Houwing
jesse.houwing at sogeti.nl


 
Reply With Quote
 
mathphoenix
Guest
Posts: n/a
 
      30th Apr 2009
Thanks for all replies.
This project is submit to codeplex, and it's far from ctp, you can just
download the code from
http://mathphoenix.codeplex.com/Sour...leCommits.aspx
I know Microsoft connector, but I am not good at English, it's a little
hard to describe clear by English for me, I am very glad if you can help me.
After download, it's easy to reproduce the problem, expand the DotNetNuke
project, open the DotNetNuke.Common directory and exclude Initialize.cs form
project, and you can pass build the DotNetNuke project, I am refractor the
solution, so you can't compiler all the project, just the DotNetNuke project
is enough for the purpose.
Some backgroud about this project:
This project is C# edition for dotnetnuke version 4.09, I use refractor
to get C# the code from debug assemble, and if I meet trouble to understand
the code, I will look back of the vb implement.
I use visual studio macro and my own VB2CS project to develop or modify
some VB function which now written by c#, this software is develop for mono
platform, so I hope all code just depend on mono and C#, I don't like to see
even one line vb code.
Because this project is not publish now, and you can just get the code
from source control, use the changset 16167 is the write one.
You may meet trouble that I am not sure weather you will meet some
Chinese character, I am sorry for this.
Thanks again.

"Morten Wennevik [C# MVP]" <(E-Mail Removed)> 写入消息
news:0A88D47E-48D9-439A-AE84-(E-Mail Removed)...
>
> I have seen cases where the error message is comletely irrelevant to the
> actual error, as well as cases where it just simply says build failed with
> no
> error messages or warnings at all (turned out it didn't like two vs
> instances
> with a database project in each solution). It is apparantly unable to
> understand Utilities, but the reason may not be so obvious. As you have
> put
> it as a using directive the most likely cause would be that you are not
> referencing the project/assembly containing the
> DotNetNuke.Common.Utilities
> classes.
>
> In your code, if you have at least one class with the namespace
> DotNetNuke.Common.Utilities in a referenced project the code should
> compile.
> There may be an error if you at the same time have a Utilities class in
> DotNetNuke.Common but the error message should in that case indicate that
> Utilities already exists.
>
> I assume you do have a class with this namespace, so there may well be a
> bug. Try removing the using directive referring to Utilities and instead
> use
> the full class name for BannerInfo and/or DataProvider. If this works,
> try
> deleting the namespace part from BannerInfo/DataProvider and see if Visual
> Studio is able to figure out where these classes are defineed (ALT+F10
> when
> the cursor is on the class name).
>
> As for using directives inside or outside the namespace. I don't think it
> matters at all as long as they are outside the class scope.
>
> If you are able to reproduce the error in a new solution you can submit a
> bug report at the Microsoft Developer Division Feedback Center
>
> https://connect.microsoft.com/VisualStudio
> (You may need to sign in to be able to submit a bug)
>
> If you rather want me to submit the bug, send me a project where this bug
> is
> reproducable and I'll be happy to submit a bug report.
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]
>
>
> "mathphoenix" wrote:
>
>> some more detail, I have use c# for many yeas, I understand the concept,
>> I
>> think it may be bug of visual studio 2008?
>> I am doing some refractor of dotnetnuke(the edition 4.09) for my own
>> purpose.
>> one file which can pass check before like this:
>>
>> namespace DotNetNuke.Services.Vendors
>> {
>> using DotNetNuke.Common;
>> using DotNetNuke.Common.Utilities;
>> using DotNetNuke.Data;
>>
>> using System;
>> using System.Collections;
>> using System.Runtime.CompilerServices;
>>
>> public class BannerController
>> {
>> public void AddBanner(BannerInfo objBannerInfo)
>> {
>> DataProvider.Instance().AddBanner(objBannerInfo.BannerName,
>> objBannerInfo.VendorId, objBannerInfo.ImageFile, objBannerInfo.URL,
>> objBannerInfo.Impressions, objBannerInfo.CPM, objBannerInfo.StartDate,
>> objBannerInfo.EndDate, objBannerInfo.CreatedByUser,
>> objBannerInfo.BannerTypeId, objBannerInfo.Description,
>> objBannerInfo.GroupName, objBannerInfo.Criteria, objBannerInfo.Width,
>> objBannerInfo.Height);
>> }
>>
>> .....
>> }
>> }
>>
>>
>> Now, i was told that error CS0234: “Utilities” is not exists in
>> namespace
>> “DotNetNuke.DotNetNuke.Common”(miss some reference?) ,
>>
>> In my opinion, no matter which file I add to this project, the error is
>> misleading, and should be a bug, or it's my fault?
>>
>> The project's default namespace is DotNetNuke, and I think it's nothing
>> about the using directive , isn't it?
>>
>> "mathphoenix" <(E-Mail Removed)> 写入消息
>> news:21AA3F68-D0C8-4C13-BB33-(E-Mail Removed)...
>> > I have a csharp project develop with vs2008, it can pass build
>> > first,
>> > when I add a new class to it, the other class in the project can't pass
>> > the compiler check, I can't check the new class now, It seem that all
>> > go
>> > wrong. anyone meet the trouble?
>> >
>> > Another question, is that different the using direction inside or
>> > beside
>> > the namespace ?

>>

 
Reply With Quote
 
mathphoenix
Guest
Posts: n/a
 
      30th Apr 2009

I am sorry for that it's my fault.
I think I know what's wrong, it's the file which I add to the project:


using System;
using System.Security;
using System.Security.Principal;
using System.Web;
using System.Web.Security;
using System.IO;
using DotNetNuke.Services.Log.EventLog;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Entities.Portals;
using System.Collections;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Common;
using System.Threading;
using DotNetNuke.Services.Scheduling;
using VB2CS;
using System.Web.Hosting;


namespace DotNetNuke.DotNetNuke.Common
{

public class Initialize
{
........
}




}

I forgot to remove the default namespace. it's the fundamental reason?

Although I can't understand why the ide was confuse by this simple mistake,
maybe is a big one ?

it's possible to reproduce the error by a simple project, but not which I am
working for, it's a huge solution and it's not suitable to illustrate the
problem.

I don't have extern time, may be you can send this bug(maybe it's not a bug)
to Microsoft connector.

even the ide told me the class is not exist, I'm sure she know it, because
the class is highlight

I am sorry to waste you time just because my careless mistake.

thanks for all replies

--
Code Your Life
mathphoenix



"Morten Wennevik [C# MVP]" <(E-Mail Removed)> 写入消息
news:0A88D47E-48D9-439A-AE84-(E-Mail Removed)...
>
> I have seen cases where the error message is comletely irrelevant to the
> actual error, as well as cases where it just simply says build failed with
> no
> error messages or warnings at all (turned out it didn't like two vs
> instances
> with a database project in each solution). It is apparantly unable to
> understand Utilities, but the reason may not be so obvious. As you have
> put
> it as a using directive the most likely cause would be that you are not
> referencing the project/assembly containing the
> DotNetNuke.Common.Utilities
> classes.
>
> In your code, if you have at least one class with the namespace
> DotNetNuke.Common.Utilities in a referenced project the code should
> compile.
> There may be an error if you at the same time have a Utilities class in
> DotNetNuke.Common but the error message should in that case indicate that
> Utilities already exists.
>
> I assume you do have a class with this namespace, so there may well be a
> bug. Try removing the using directive referring to Utilities and instead
> use
> the full class name for BannerInfo and/or DataProvider. If this works,
> try
> deleting the namespace part from BannerInfo/DataProvider and see if Visual
> Studio is able to figure out where these classes are defineed (ALT+F10
> when
> the cursor is on the class name).
>
> As for using directives inside or outside the namespace. I don't think it
> matters at all as long as they are outside the class scope.
>
> If you are able to reproduce the error in a new solution you can submit a
> bug report at the Microsoft Developer Division Feedback Center
>
> https://connect.microsoft.com/VisualStudio
> (You may need to sign in to be able to submit a bug)
>
> If you rather want me to submit the bug, send me a project where this bug
> is
> reproducable and I'll be happy to submit a bug report.
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]
>
>
> "mathphoenix" wrote:
>
>> some more detail, I have use c# for many yeas, I understand the concept,
>> I
>> think it may be bug of visual studio 2008?
>> I am doing some refractor of dotnetnuke(the edition 4.09) for my own
>> purpose.
>> one file which can pass check before like this:
>>
>> namespace DotNetNuke.Services.Vendors
>> {
>> using DotNetNuke.Common;
>> using DotNetNuke.Common.Utilities;
>> using DotNetNuke.Data;
>>
>> using System;
>> using System.Collections;
>> using System.Runtime.CompilerServices;
>>
>> public class BannerController
>> {
>> public void AddBanner(BannerInfo objBannerInfo)
>> {
>> DataProvider.Instance().AddBanner(objBannerInfo.BannerName,
>> objBannerInfo.VendorId, objBannerInfo.ImageFile, objBannerInfo.URL,
>> objBannerInfo.Impressions, objBannerInfo.CPM, objBannerInfo.StartDate,
>> objBannerInfo.EndDate, objBannerInfo.CreatedByUser,
>> objBannerInfo.BannerTypeId, objBannerInfo.Description,
>> objBannerInfo.GroupName, objBannerInfo.Criteria, objBannerInfo.Width,
>> objBannerInfo.Height);
>> }
>>
>> .....
>> }
>> }
>>
>>
>> Now, i was told that error CS0234: “Utilities” is not exists in
>> namespace
>> “DotNetNuke.DotNetNuke.Common”(miss some reference?) ,
>>
>> In my opinion, no matter which file I add to this project, the error is
>> misleading, and should be a bug, or it's my fault?
>>
>> The project's default namespace is DotNetNuke, and I think it's nothing
>> about the using directive , isn't it?
>>
>> "mathphoenix" <(E-Mail Removed)> 写入消息
>> news:21AA3F68-D0C8-4C13-BB33-(E-Mail Removed)...
>> > I have a csharp project develop with vs2008, it can pass build
>> > first,
>> > when I add a new class to it, the other class in the project can't pass
>> > the compiler check, I can't check the new class now, It seem that all
>> > go
>> > wrong. anyone meet the trouble?
>> >
>> > Another question, is that different the using direction inside or
>> > beside
>> > the namespace ?

>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reconstructing Class Project - Solution and Project files gone?VS.NET 2005 wildman@noclient.net Microsoft Dot NET 0 2nd Feb 2008 12:14 PM
Problem using regular class library project in device project enantiomer Microsoft Dot NET Compact Framework 7 18th Feb 2006 05:32 PM
how do use a class from another project? Flip Microsoft ASP .NET 3 1st Dec 2005 08:29 PM
InitializeComponent is generating the wrong code for my custom class. Calling it's base class constructor jrhoads23@hotmail.com Microsoft Dot NET Framework Forms 0 1st Feb 2005 07:10 PM
How can an asp.net project by pulling in a code-behind class from another project? moondaddy Microsoft ASP .NET 4 27th Jul 2004 09:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:05 AM.