Solved

Namespace problem in my usercontrol

Posted on 2004-09-29
5
213 Views
Last Modified: 2010-04-15
Hi Experts,

Here is the problem:

namespace MyDirectory.UserControls.MyDirectory.File
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;

public class NewFile : System.Web.UI.UserControl
     {
... code
                }
}

In my Asp .Net UserControl, if in the code, I want to use my other namespace like MyDirectory.MyDirectory.OtherNameSpace, then Visual Studio debugger tells me the namespace is unknown and I can only access to UserControls.MyDirectory.
The 2 namespaces MyDirectory.UserControls.MyDirectory shadows MyDirectory.MyDirectory. Why ?

How to use this namespace without any namespace title modify ?

Thanks in advance for your help. Hope I was clear.

Note that outside the usercontrol namespace, I can use both.
0
Comment
Question by:noulouk
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12187152
Try,

using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;
using MyDirectory.MyDirectory.OtherNameSpace;

namespace MyDirectory.UserControls.MyDirectory.File
{
public class NewFile : System.Web.UI.UserControl
     {
... code
                }
}
0
 
LVL 9

Author Comment

by:noulouk
ID: 12187966
Thanks Chester_M_Ragel,

I already try this and works well outside the code.
But if I want to use it inside the code the first MyDirectory is UserControls.MyDirectory namespace ?????????? (ie Visual Studio hover menu) .
Is this a Visual Studio bug ?
0
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12188159
Its actually not related with VS.Net. Its with .net Framework. Thats how it works.  B'cos of the nesting of MyDirectory and how .net interprets it, you can't reffer it like that.
0
 
LVL 9

Author Comment

by:noulouk
ID: 12188197
Is there another way to do what I want or have I to change my namespace name ? If yes, hope framework 2.0 will solve this bug.
0
 
LVL 6

Accepted Solution

by:
Chester_M_Ragel earned 500 total points
ID: 12188227
I'm not sure about other ways.. I'll recommend to use some other namespace. Also, In .Net FW beta 2.0 its the same:(
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question