all groups > asp.net building controls > october 2005 >
You're in the

asp.net building controls

group:

Problem using an assembly


Re: Problem using an assembly shiv_koirala NO[at]SPAM yahoo.com
10/9/2005 12:57:59 AM
asp.net building controls:
HI
Can u see in the behind code is the ASCX declared. ASCX can work
independent of assemblies

-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/
Problem using an assembly Nathan Sokalski
10/9/2005 1:24:20 AM
I have a User Control that I created (.ascx & .ascx.vb file pair) that I =
am trying to put in a separate assembly. I know that the User Control =
works when it is in the same project and is compiled along with the =
project it is used in, so the problem is obviously something I am doing =
wrong with the references or something. My current code registers the =
assembly as:

<%@ Page Language=3D"vb" AutoEventWireup=3D"false" =
Codebehind=3D"DatePickerTest.aspx.vb" =
Inherits=3D"WebApplication1.DatePickerTest"%>

<%@ Register TagPrefix=3D"NateCtrl" Namespace=3D"NateCtrl" =
Assembly=3D"NateCtrl" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>DatePickerTest</title>

<meta content=3D"Microsoft Visual Studio .NET 7.1" name=3D"GENERATOR">

<meta content=3D"Visual Basic .NET 7.1" name=3D"CODE_LANGUAGE">

<meta content=3D"JavaScript" name=3D"vs_defaultClientScript">

<meta content=3D"http://schemas.microsoft.com/intellisense/ie5" =
name=3D"vs_targetSchema">

</HEAD>

<body>

<form id=3D"Form1" method=3D"post" runat=3D"server">

<NateCtrl:DatePicker id=3D"DatePickerCtrl" =
runat=3D"server"></NateCtrl:DatePicker><BR><BR>

<asp:label id=3D"lblSelectedDate" runat=3D"server"></asp:label>

<asp:button id=3D"btnRefresh" runat=3D"server" Font-Bold=3D"True" =
EnableViewState=3D"False" Text=3D"Refresh"></asp:button><BR><BR>

<asp:button id=3D"btnXmas2000" runat=3D"server" Font-Bold=3D"True" =
EnableViewState=3D"False" Text=3D"Christmas 2000" =
CausesValidation=3D"False"></asp:button><BR><BR>

<asp:button id=3D"btnMyBirthday" runat=3D"server" Font-Bold=3D"True" =
EnableViewState=3D"False" Text=3D"My Birthday" =
CausesValidation=3D"False"></asp:button><BR><BR>

<asp:button id=3D"btnNewYear95" runat=3D"server" Font-Bold=3D"True" =
EnableViewState=3D"False" Text=3D"New Year's 1995" =
CausesValidation=3D"False"></asp:button>

</form>

</body>

</HTML>


When I attempt to execute the page, I recieve the following error:

=20
Server Error in '/WebApplication1' Application.=20
-------------------------------------------------------------------------=
-------

Object reference not set to an instance of an object.=20
Description: An unhandled exception occurred during the execution of the =
current web request. Please review the stack trace for more information =
about the error and where it originated in the code.=20

Exception Details: System.NullReferenceException: Object reference not =
set to an instance of an object.

Source Error:=20

Line 62: ViewState.Add("stopyear", Date.Today.Year + 25)
Line 63: For i As Integer =3D 1 To 12
Line 64: ddlMonth.Items.Add(New =
System.Web.UI.WebControls.ListItem(System.Globalization.DateTimeFormatInf=
o.CurrentInfo.GetMonthName(i), CStr(i)))
Line 65: Next
Line 66: Me.CreateLists()=20

Source File: c:\inetpub\wwwroot\NateCtrl\DatePicker.ascx.vb Line: 64=20

Stack Trace:=20

[NullReferenceException: Object reference not set to an instance of an =
object.]
NateCtrl.DatePicker.Page_Load(Object sender, EventArgs e) in =
c:\inetpub\wwwroot\NateCtrl\DatePicker.ascx.vb:64
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +750
=20


What am I missing here? Thanks.
--=20
Nathan Sokalski
njsokalski@hotmail.com
Re: Problem using an assembly Ken Tucker [MVP]
10/9/2005 6:50:36 AM
Hi,

Your @Register is wrong here is an example from one of my
projects.

<%@ Register TagPrefix="uc1" TagName="RssViewer" Src="RssViewer.ascx" %>

If drag the control from the solution explorer to the form you
want the control on. VB.net will add the @ register for you.

Ken
----------------
[quoted text, click to view]
I have a User Control that I created (.ascx & .ascx.vb file pair) that I am
trying to put in a separate assembly. I know that the User Control works
when it is in the same project and is compiled along with the project it is
used in, so the problem is obviously something I am doing wrong with the
references or something. My current code registers the assembly as:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="DatePickerTest.aspx.vb"
Inherits="WebApplication1.DatePickerTest"%>
<%@ Register TagPrefix="NateCtrl" Namespace="NateCtrl" Assembly="NateCtrl"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DatePickerTest</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<NateCtrl:DatePicker id="DatePickerCtrl"
runat="server"></NateCtrl:DatePicker><BR><BR>
<asp:label id="lblSelectedDate" runat="server"></asp:label>
<asp:button id="btnRefresh" runat="server" Font-Bold="True"
EnableViewState="False" Text="Refresh"></asp:button><BR><BR>
<asp:button id="btnXmas2000" runat="server" Font-Bold="True"
EnableViewState="False" Text="Christmas 2000"
CausesValidation="False"></asp:button><BR><BR>
<asp:button id="btnMyBirthday" runat="server" Font-Bold="True"
EnableViewState="False" Text="My Birthday"
CausesValidation="False"></asp:button><BR><BR>
<asp:button id="btnNewYear95" runat="server" Font-Bold="True"
EnableViewState="False" Text="New Year's 1995"
CausesValidation="False"></asp:button>
</form>
</body>
</HTML>

When I attempt to execute the page, I recieve the following error:


Server Error in '/WebApplication1' Application.


Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 62: ViewState.Add("stopyear", Date.Today.Year + 25)
Line 63: For i As Integer = 1 To 12
Line 64: ddlMonth.Items.Add(New
System.Web.UI.WebControls.ListItem(System.Globalization.DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
CStr(i)))
Line 65: Next
Line 66: Me.CreateLists()


Source File: c:\inetpub\wwwroot\NateCtrl\DatePicker.ascx.vb Line: 64

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
NateCtrl.DatePicker.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\NateCtrl\DatePicker.ascx.vb:64
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +750




What am I missing here? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

AddThis Social Bookmark Button