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
Share on LinkedIn
Quick Share: Your custom post text has been copied to your clipboard! Click the button below to open LinkedIn's share dialog, then paste it.
💡 Tip: LinkedIn will open in a new tab. Use Ctrl+V (or Cmd+V on Mac) to paste your text.
Note: LinkedIn will show the article preview. You can add your custom text above it.