I have a server control as a class within my MySite
assembly (i.e., my site's project not only contains aspx files but also contains server controls which those aspx files reference). I use the following code within an aspx file:
<%@ Register Assembly="MySite" Namespace="MySite.misc" TagPrefix="TAC" %>
...
<TAC:CustomACM ID="myID" runat="server" />
The class's code is as follows:
namespace MySite.misc
{
public class CustomACM : AutoCompleteExtender, INamingContainer
{
//...
}
}
The site works and compiles perfectly, but IntelliSense breaks within myID's children. Changing the namespace within both the class and the register directive to MySiteSC.misc
fixes this, though using MySite.miscSC
does not help. Neither MySiteSC
nor miscSC
is used elsewhere within my solution, and no other CustomACM
class exists within any namespace.
ReSharper underlines "MySite" (i.e., part of the namespace within the register directive) in red with tooltip, "Register Directive is unused and can be safely removed \n Ambiguous Reference." Disabling ReSharper prevents this error from showing up, but does not fix the problem.
Is it possible for me to fix this problem without changing the namespace of the CustomACM control (and without moving the CustomACM control to a different assembly)?
An ambiguous reference is the situation in which a sentence contains a pronoun that could refer to either of two nouns in the same sentence or (using our new vocabulary word) where we have a pronoun but we aren't sure what its antecedent is.
I had similar problem that the class had ambiguous reference for the SAME namespace, so I deleted a specific Project (under Dependencies/{my.prj.name}. API) which had duplicated reference. After that I referenced Project back with using of CTRL+. Hope it'll work for you.
ambiguity error is that you named field and property tha same name "colour". change the property definition f.e. public string Colour { get { return colour;} set { colour = value;} } Copy link CC BY-SA 2.5. Follow this answer to receive notifications.
Resharper is buggy here IMHO. The problem can be solved by clearing the caches of ReSharper (ReSharper > Options > General > Clear Caches), then restarting VS and build again. The message should disappear then. I know, that this isn't a solution really but it works.
To enable your control to be used declaratively in a page, you must map a tag prefix to your control's namespace.
In your custom server control project, have you added the TagPrefixAttribute
attribute in your file AssemblyInfo.cs?
You have to add this line at the end of the file to create a mapping between the namespace and the prefix.
[assembly: TagPrefix("MySite.misc", "TAC")]
Add this line at the beginning of the file:
Using System.Web.UI;
After you do that, whenever you drag a custom server control from the toolbox to the .aspx page, VS should automatically add the Register directive.
Alternatively, instead of using register directive you could specify the tag prefix/namespace mapping in the web.config file if your custom control will be used in multiple pages in a web application.
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="TAC" Assembly="MySite"
namespace="MySite.misc">
</add>
</controls>
</pages>
</system.web>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With