Object reference not set...

  • Thread starter Brian Vallelunga
  • Start date
B

Brian Vallelunga

This is very strange. I have a server control that I built called "Test". It
is in the namespace "Vallelunga.Guestbook". The code for the usercontrol
looks like this:

namespace Vallelunga.Guestbook
{
public class Test : System.Web.UI.Control
{
public Test()
{
this.Context.Trace.Write("Test constructor");
}

protected override void Render(HtmlTextWriter output)
{
output.Write("Hello World");
}
}
}

This is compiled into a dll called Vallelunga.Guestbook.dll

That's about as simple as I can get. When I put a reference to it on a page,
I use:

<%@ Register Namespace="Vallelunga.Guestbook" tagprefix="guestbk"
Assembly="Vallelunga.Guestbook" %>

on the page...

<form runat="server">
<h1>Test</h1>
<guestbk:Test runat="server" id="test1" />
</form>




Does anyone see anything wrong with this? I've made much more complicated
controls before, so I think there must be some stupid error somewhere.
Anyway, when I run the page, I get an error highlighting the line:

this.Context.Trace.Write("Test constructor");


The error is "Object reference not set to an instance of an object"

if I comment out that line, the page loads, but no "Hello World" is ever
found. Nor does the control show in the control tree. It is like my
HtmlTextWriter doesn't have a context to write to or something. Any ideas?

Thanks,

Brian
 
B

Brian Vallelunga

I've looked into this a bit more. My dll works fine when on an IIS server I
have access to. The problem seems to only show itself when I use the Web
Matrix server. Any idea why?

Brian
 

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,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top