Solved

Namespace problem in my usercontrol

Posted on 2004-09-29
5
211 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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