noulouk
asked on
Namespace problem in my usercontrol
Hi Experts,
Here is the problem:
namespace MyDirectory.UserControls.M yDirectory .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.WebContro ls;
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.Ot herNameSpa ce, then Visual Studio debugger tells me the namespace is unknown and I can only access to UserControls.MyDirectory.
The 2 namespaces MyDirectory.UserControls.M yDirectory 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.
Here is the problem:
namespace MyDirectory.UserControls.M
{
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.WebContro
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.Ot
The 2 namespaces MyDirectory.UserControls.M
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.
ASKER
No, I don't want to change it. It works inside all my app except for usercontrol.
Or if I change it, this will be:MyProjectTitle.MyDirect ory.UserCo ntrols.MyD irectory. So same problem.
Sorry for the headhache ;-)
Or if I change it, this will be:MyProjectTitle.MyDirect
Sorry for the headhache ;-)
Within your user control, add a using statement at the top of the file:
using MyDirectory.MyDirectory.Ot herNameSpa ce;
Just because they're in the same project/DLL doesn't mean they can automatically reference each other if their namespaces are different.
using MyDirectory.MyDirectory.Ot
Just because they're in the same project/DLL doesn't mean they can automatically reference each other if their namespaces are different.
ASKER
Thanks Thogek,
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 ?
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 ?
Huh?
It sounds like you're dealing with a namespace clash, but the details are very unclear from the above. If this is correct, what exactly are the two namespaces of yours that are clashing?
It sounds like you're dealing with a namespace clash, but the details are very unclear from the above. If this is correct, what exactly are the two namespaces of yours that are clashing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, you save my life.
Best, Nauman.