Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

user control - CS0246 error

  Asked By: Demyan    Date: May 13    Category: Asp.net    Views: 981

I have researched this error and found several references, but still
nothing solved. Essentially I have:
myUser control in myUser.ascx with codebehind in myUser.ascx.cs
Namespace is myUseruc

myWebForm is myWebForm.aspx with codebehind myWebForm.aspx.cs
myWebForm has an instance of myUser control called myUserInst

In myWebForm.aspx I register the control with:
<%@ Register TagPrefix="uc1" TagName="myUser" src="myUser.scx" %>
and on the page in <form> I have:
<uc1:myUser id="myUser1" runat="server"></uc1:myUser>
The codebehind in myWebForm.aspx.cs includes:
public myUseruc.myUser myUser1;
I also reference the instance of myUser1 in the code to manipulate a
property or call a method, and the intellisense recognizes the object
just fine.

In myUser.ascx I have:

<%@ Control Language="c#" AutoEventWireup="false"
src="myUser.ascx.cs" Inherits="myUseruc.myUser"
classname="myUser" %>

This originally ran OK on my local PC, but I never could get it to
run on our student server. I get the CS0246 error - can't find the
user control reference. Also on my local PC, I no longer get it to
run in start without debug mode -- I get
the "CS1595: 'myUseruc.myUser' is defined in multiple places" error

We (including the instructor, and a Microsoft Rep) are thinking this
is a simple fix, like maybe the incorrect reference to the control. I
read an article that talks about compiling the control. Don't know if
that's it. The Microsoft walkthrough tutorial on user controls does
not explain this problem.



3 Answers Found

Answer #1    Answered By: Dang Tran     Answered On: May 13

For starters you have <%@ Register TagPrefix="uc1" TagName="myUser" src="myUser.scx" %>
which should be
<%@ Register TagPrefix="uc1" TagName="myUser" src="myUser.ascx" %>

repost of this doesn't fix  it.

Answer #2    Answered By: Jamie Roberts     Answered On: May 13

owever, this was only a typo when I entered
the question. The actual code  is correct, just as you posted.
but that's not what is wrong. I still open to suggestions.

Answer #3    Answered By: Flynn Jones     Answered On: May 13

Does it compile ???

If not ::

'myUseruc.myUser' is a class not an object or control.

So it looks like you may have a different version of your assembly still registered with the framework.
This can happen when you start  renaming assemblies and namespaces and so forth, or moving stuff baout.

Try changing the name of the class or namespace and recompile. It should work.

If that works, rename things back again and use gacutil to get rid of old assemblies in the cache and manually delete older versions with a different name. Redo all of your references  to dll's if you need to.

Didn't find what you were looking for? Find more on user control - CS0246 error Or get search suggestion and latest updates.