Home All Groups Group Topic Archive Search About

Problem with Custom Web Controls in Visual Studio 2005

Author
29 Nov 2005 7:04 PM
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>

Author
30 Nov 2005 7:42 PM
Pipo
Can you post the control code?


<swesor***@gmail.com> schreef in bericht
Show quoteHide quote
news:1133291062.689242.316750@g44g2000cwa.googlegroups.com...
> 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>
>
Author
8 Dec 2005 5:14 PM
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.
Author
8 Dec 2005 7:27 PM
swesorick
After further research, granting FullTrust to the UNC Path of the
webroot folder seems to have solved my problem.

The instructions at this URL helped:
http://support.microsoft.com/?id=320268