06 March 2007

Solution to "is null or not an object" error with ScriptService

I just spent the last few hours trying to track down why I kept getting an "is null or not an object" error when setting up a service with a ScriptService attribute.

I started my coding with a PageMethods implementation, but moved to a ScriptReference implementation because I need to call the service from within a user control, which is not supported.  During that conversion I left the "static" keyword in the method declaration.  Making the method static prevents the service from being registered, hence the error.

Actually, the script tag was rendered with jsdebug, but the only thing inside of the tag was a "1" and not the web service client class registration.

Removing the static keyword solved the issue.

I hope this helps

Jon

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# new coder said:

thanks so much - this really helped a lot

17 December 07 at 10:06 PM
# Andy Thorne said:

I can't login to my shop in IE7 because of the"is null or not an object" problem.

I read your solution above but don't understand? What's the static keyword and how do I remove it?

Thanks,

Andy

30 September 08 at 6:05 AM
# jongallant said:

Andy,

Can you give me more info about your problem?  The solution above is for WCF, which is doesn't sound like you are using.

Is it a JavaScript error you are seeing?

Thanks,

Jon

30 September 08 at 1:11 PM
# Tom Bailey said:

For those embedding the JW Player, this naging eror can also occur if there are undefined variables in either the script block that displays the player or in the <object block as well. IE does not seem to differentiate between a javascript error and an Object error.

Go Figure!

-Tom

02 January 09 at 5:12 PM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker