Problem with Custom Web Controls in Visual Studio 2005

S

swesorick

So, I have a custom web control that inherits from the standard asp.net
Textbox control.
When I add this control to my web page in Visual Studio 2005, I get the
following errors in my Error List:

Error 1 Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed. \\myserver\WebRoot\mypage.aspx 81

Error 29 Element 'MyTextBox' is not a known element. This can occur if
there is a compilation error in the Web
site. \\myserver\WebRoot\mypage.aspx 81 20 \\myserver\WebRoot\

The web control is in a separate vb.Net project from the website. Both
are in the same solution. The webcontrol is referenced as a project
reference from the website.

Whenever I try to reference this control from the Server side code, I
get the error: "txtMyTextBox is not declared." in the IDE

However, the site runs ok, when I actually visit the website. Also,
when I switch to Design Mode, it appears to render the control ok.
What could be causing this? How do I get the IDE to know about my
control and stop yelling at me about it?

The ASP.Net html looks like this:
<%@ Page Language="VB" MasterPageFile="~/myMaster.master"
AutoEventWireup="false" CodeFile="mypage.aspx.vb" Inherits="mypage" %>
<%@ MasterType VirtualPath="~/myMaster.master" %>
<%@ Register Assembly="MyControls" Namespace="MyControls"
TagPrefix="MyC"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain"
runat="Server">
<MyC:MyTextBox ID="txtMyTextBox" runat="server" TextMode="Password"
MaxLength="50"></MyC:MyTextBox>
</asp:Content>
 
S

swesorick

The code for the custom control can be as simple as just:
Public Class MyTextBox
Inherits System.Web.UI.WebControls.TextBox
End Class

And I still get the error. The weird thing is, these errors only occur
in the IDE. The website itself runs fine.

Also, the error only occurs when the website is located on a fileshare
on a different server from my development box. If my website is
located in c:\inetpub\wwwroot, everything is fine. When the website is
in the \\myserver\WebRoot\ folder is when I get the error.

This leads me to believe the problem is with the
System.Web.AspNetHostingPermission permission error. Is there any way
I can tell my computer to trust the \\myserver\WebRoot\ folder, the
same way it trusts the c:\inetpub\wwwroot folder? (Or at least tell it
to trust that folder enough to let my custom control run) I've dug
into the configuration files in my
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG folder, but I am
having a hard time figuring out which files and settings I need to
change.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top