Showing posts with label view. Show all posts
Showing posts with label view. Show all posts

Saturday, March 24, 2012

object reference not set to an instance of an object

Hi,

Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using Cassini
to view.

I see this error discussed all over the net but don't seem to find a way to
resolve my particular grief -- which I am sure is not unique. Here are my
basic steps:

1) create a masterpage -- add some simple graphics to the header.
2) add a new web form that references the master page and attaches a code
behind file. (actually added 3 files referencing the same mpage -- each
errors)
3) add some basic html into the placeholder auto-created in the web form
page, ie:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

</asp:Content>

4) view the page and it all views okay.

But when I look at the page in design mode -- the Content placeholder shows
this error -- and it is referenced in the error list as well.

================
Error creating control - Content1
object reference not set to an instance of an object
================

Can anyone give me a heads up as to what this error means, how to get rid of
it, etc. I am guessing that it wants me to declare an object -- but where
(assuming codebehind file) and I am wondering why vstudio doesn't auto do
it? - which makes me think my guess is wrong.

thankssave your project , close out and reopen, that usually clears that problem up for me.

"thersitz" <thersitz@.gmail.comwrote in message news:uSQH0crKHHA.1240@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hi,
>
Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using Cassini to view.
>
I see this error discussed all over the net but don't seem to find a way to resolve my particular grief -- which I am sure is not
unique. Here are my basic steps:
>
1) create a masterpage -- add some simple graphics to the header.
2) add a new web form that references the master page and attaches a code behind file. (actually added 3 files referencing the
same mpage -- each errors)
3) add some basic html into the placeholder auto-created in the web form page, ie:
>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
>
</asp:Content>
>
>
4) view the page and it all views okay.
>
But when I look at the page in design mode -- the Content placeholder shows this error -- and it is referenced in the error list
as well.
>
================
Error creating control - Content1
object reference not set to an instance of an object
================
>
Can anyone give me a heads up as to what this error means, how to get rid of it, etc. I am guessing that it wants me to declare an
object -- but where (assuming codebehind file) and I am wondering why vstudio doesn't auto do it? - which makes me think my guess
is wrong.
>
thanks
>
>
>


Thanks Jon. I saw that suggestion in one of my google returns and tried
it -- but to no avail.

I've been playing around a bit and have noticed that this error does not
show until I paste in some basic html. I am going slowly into this aspNet
thing and am still using some traditional html -- div, p, table -- as i get
a feel for vstudio etc -- not using the html controls.

So my html is producing the error -- but why?

"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot comwrote in message
news:OUl5vjrKHHA.448@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

save your project , close out and reopen, that usually clears that problem
up for me.
>
>
"thersitz" <thersitz@.gmail.comwrote in message
news:uSQH0crKHHA.1240@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using
>Cassini to view.
>>
>I see this error discussed all over the net but don't seem to find a way
>to resolve my particular grief -- which I am sure is not unique. Here are
>my basic steps:
>>
>1) create a masterpage -- add some simple graphics to the header.
>2) add a new web form that references the master page and attaches a code
>behind file. (actually added 3 files referencing the same mpage -- each
>errors)
>3) add some basic html into the placeholder auto-created in the web form
>page, ie:
>>
><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
>Runat="Server">
>>
></asp:Content>
>>
>>
>4) view the page and it all views okay.
>>
>But when I look at the page in design mode -- the Content placeholder
>shows this error -- and it is referenced in the error list as well.
>>
>================
>Error creating control - Content1
>object reference not set to an instance of an object
>================
>>
>Can anyone give me a heads up as to what this error means, how to get rid
>of it, etc. I am guessing that it wants me to declare an object -- but
>where (assuming codebehind file) and I am wondering why vstudio doesn't
>auto do it? - which makes me think my guess is wrong.
>>
>thanks
>>
>>
>>


>
>


Well I have narrowed the source of the error to this piece of code:

<!--#include file="imageBar.inc" -->

So I just need to come up with an aspnet version of this code.

thanks

"thersitz" <thersitz@.gmail.comwrote in message
news:uSQH0crKHHA.1240@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hi,
>
Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using
Cassini to view.
>
I see this error discussed all over the net but don't seem to find a way
to resolve my particular grief -- which I am sure is not unique. Here are
my basic steps:
>
1) create a masterpage -- add some simple graphics to the header.
2) add a new web form that references the master page and attaches a code
behind file. (actually added 3 files referencing the same mpage -- each
errors)
3) add some basic html into the placeholder auto-created in the web form
page, ie:
>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
>
</asp:Content>
>
>
4) view the page and it all views okay.
>
But when I look at the page in design mode -- the Content placeholder
shows this error -- and it is referenced in the error list as well.
>
================
Error creating control - Content1
object reference not set to an instance of an object
================
>
Can anyone give me a heads up as to what this error means, how to get rid
of it, etc. I am guessing that it wants me to declare an object -- but
where (assuming codebehind file) and I am wondering why vstudio doesn't
auto do it? - which makes me think my guess is wrong.
>
thanks
>
>
>


Try just running that piece of code by itself (copy it to a blank web page)
It sounds like something in particular on that page might be causing the
problem.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"thersitz" <thersitz@.gmail.comwrote in message
news:uybzSKsKHHA.4460@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Well I have narrowed the source of the error to this piece of code:
>
<!--#include file="imageBar.inc" -->
>
So I just need to come up with an aspnet version of this code.
>
thanks
>
>
>
>
"thersitz" <thersitz@.gmail.comwrote in message
news:uSQH0crKHHA.1240@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using
>Cassini to view.
>>
>I see this error discussed all over the net but don't seem to find a way
>to resolve my particular grief -- which I am sure is not unique. Here are
>my basic steps:
>>
>1) create a masterpage -- add some simple graphics to the header.
>2) add a new web form that references the master page and attaches a code
>behind file. (actually added 3 files referencing the same mpage -- each
>errors)
>3) add some basic html into the placeholder auto-created in the web form
>page, ie:
>>
><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
>Runat="Server">
>>
></asp:Content>
>>
>>
>4) view the page and it all views okay.
>>
>But when I look at the page in design mode -- the Content placeholder
>shows this error -- and it is referenced in the error list as well.
>>
>================
>Error creating control - Content1
>object reference not set to an instance of an object
>================
>>
>Can anyone give me a heads up as to what this error means, how to get rid
>of it, etc. I am guessing that it wants me to declare an object -- but
>where (assuming codebehind file) and I am wondering why vstudio doesn't
>auto do it? - which makes me think my guess is wrong.
>>
>thanks
>>
>>
>>


>
>


Try just running that piece of code by itself (copy it to a blank web page)
It sounds like something in particular on that page might be causing the
problem.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"thersitz" <thersitz@.gmail.comwrote in message
news:uybzSKsKHHA.4460@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Well I have narrowed the source of the error to this piece of code:
>
<!--#include file="imageBar.inc" -->
>
So I just need to come up with an aspnet version of this code.
>
thanks
>
>
>
>
"thersitz" <thersitz@.gmail.comwrote in message
news:uSQH0crKHHA.1240@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Very new to asp.net. Using VStudio 2005 on an XP Pro machine. Using
>Cassini to view.
>>
>I see this error discussed all over the net but don't seem to find a way
>to resolve my particular grief -- which I am sure is not unique. Here are
>my basic steps:
>>
>1) create a masterpage -- add some simple graphics to the header.
>2) add a new web form that references the master page and attaches a code
>behind file. (actually added 3 files referencing the same mpage -- each
>errors)
>3) add some basic html into the placeholder auto-created in the web form
>page, ie:
>>
><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
>Runat="Server">
>>
></asp:Content>
>>
>>
>4) view the page and it all views okay.
>>
>But when I look at the page in design mode -- the Content placeholder
>shows this error -- and it is referenced in the error list as well.
>>
>================
>Error creating control - Content1
>object reference not set to an instance of an object
>================
>>
>Can anyone give me a heads up as to what this error means, how to get rid
>of it, etc. I am guessing that it wants me to declare an object -- but
>where (assuming codebehind file) and I am wondering why vstudio doesn't
>auto do it? - which makes me think my guess is wrong.
>>
>thanks
>>
>>
>>


>
>


I am having the same issue. I have a master page with one editable region. When I use the master and place plain html 4.0 data in the editable region it creates this error while in design view. Error Creating Control - Content1 Object Reference not set to an instance of an object.

The page renders correctly and build correctly. I have restart and tried various data. Is it becuase I am creating the page in another folder other than the master page. Even though it is looking for web root is it confused?

The page directive looks like this:

<%@. Page Language="C#" MasterPageFile="~/public/Public.master" >>The rest is normal stuff.

My Directory structure is:

/
/public
/public/info
/public/news
/public/...more folders

my master is in /public/Public.master

The pages I am having issues in are the subfolders

/public/info/page_one.aspx

The files in the same folder as the master works fine:
/public/public.Master
/public/Default.aspx

Thanks

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
you may find the answer here.

http://odetocode.com/Articles/450.aspx
Mike

On Jan 21, 9:20 pm, Tom wrote:

Quote:

Originally Posted by

I am having the same issue. I have amasterpagewith one editable region. When I use themasterand place plain html 4.0 data in the editable region it creates this error while in design view. Error Creating Control - Content1ObjectReferencenotsetto aninstanceof anobject.
>
Thepagerenders correctly and build correctly. I have restart and tried various data. Is it becuase I am creating thepagein another folder other than themasterpage. Even though it is looking for web root is it confused?
>
Thepagedirective looks like this:
>
<%@.PageLanguage="C#" MasterPageFile="~/public/Public.master" >>The rest is normal stuff.
>
My Directory structure is:
>
/
/public
/public/info
/public/news
/public/...more folders
>
mymasteris in /public/Public.master
>
The pages I am having issues in are the subfolders
>
/public/info/page_one.aspx
>
The files in the same folder as themasterworks fine:
/public/public.Master
/public/Default.aspx
>
Thanks
>
EggHeadCafe.com - .NET Developer Portal of Choicehttp://www.eggheadcafe.com

Thursday, March 22, 2012

Object reference not set to an instance of an object when attempting to view published web

Hi,

I have been developing an asp web site in VS2005, which builds and runs fine from the development environment. However when i publish it to a local test directory (Inetpub/wwwroot/TFL1617) and attempt to view it i get the above error and the following:

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) +1841
System.Web.Hosting.ISAPIWorkerRequest.ReadRequestHeaders() +121
System.Web.Hosting.ISAPIWorkerRequest.GetKnownRequestHeader(Int32 index) +126
System.Web.Hosting.ISAPIWorkerRequestInProc.GetKnownRequestHeader(Int32 index) +104
System.Web.HttpRequest.FillInHeadersCollection() +30
System.Web.HttpRequest.get_Headers() +70
System.Web.TraceContext.InitRequest() +603
System.Web.TraceContext.VerifyStart() +170
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +3445423
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +300


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

IIS is version 5.1

Has anyone got any idea what the problem might be or how i can find out a little more about it?

Thanks

Can you give a code snippet and show where the error is occuring?

Thats the problem. I have no idea where it is occuring. It is the message i get when i try to load any web page from the site, not when i try to run a task using a control. I have also tried loading a blank test page with no controls / code associated with it (though it might have been an error with a custom control, it returns the same thing. So i'm thinking it must be some sort of IIS setup problem . . . any ideas?

Thanks


Do you have your local computer configured for ASP.NET 2.0?

Thanks for your suggestion but yes, i believe I do. In IIS i have both the 'Default Web Sites' and specific application nodes set to asp v2.0 via 'properties' -> 'asp.net' tab.


I have just attempted to publish a simple web site. I consists of only a Default.aspx page, which contains a single label control. I get a similar error, but slightly different stack trace:

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) +1618
System.Web.Security.WindowsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs) +593
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

So presumably it must be an IIS configuration issue as it is using a clean web.config. Any thoughts on a resolution?

Thanks again.


It may in fact be a framework issue. Simple .htm & .asp files load ok through IIS, the problem is with .aspx files??

Can anyone suggest anything?


Thanks.


After many high speed collisions between my head and a brick wall, all i needed to do was register the ASP.NET extensions in IIS, as i had installed IIS after the .NET framework. Simply go to command window and run aspnet_regiis -i (The -i option installs the needed associations in IIS) in the WINDOWS\Microsoft.NET\Framework\vX.X.XXXX directory.

I hope this may help someone. :)


It did. I just configured my new laptop and had forgotten this step. :) Thanks


Just helped me :-)Thx!