.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Web Service and Base Class Sub Routines

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net


I have several Web Services that I call using jQuery, they are all <WebMethod()> _    Public Function and return either a boolean or string, depending on the function.

I have some Web Service functions, where I would like to call sub routines I have in my base class, they are Public Sub's.

When I add a call of a sub routine in the Web Service function, I get a blue line that says 'Object reference not set to an instance of an object'.  If I change the sub routine to Public Shared Sub, then the blue line and error go away, but I get other errors from the calls I was successfully making to the base class routines before.

Is there a way to get these two to work together?

View Complete Post

More Related Resource Links

Web Service to inherit from a Custom Base Class that inherits System.Web.Services.WebMethod instead


Hi All,

Recently, I tried to get my Web Service class to inherit from a custom base class that inherits from System.Web.Services.WebMethod instead of the System.Web.Services.WebMethod directly.

However, I've been getting Error 500.

Public Class Service1
    Inherits BaseClass
    <System.Web.Services.WebMethod()> _
    Public Function GetSessionID() As String
        GetSessionID = Me.Session.SessionID
    End Function
End Class


public class BaseClass
    Inherits System.Web.Services.WebService

    public property Property1 as string
    public property Property2 as string

End Class


Please kindly assist.

Thank you in advance.

Warmest Regards,


How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



Can I replace the EntityObject as base-class in Entity Designer 3.5 sp1?


I'm using EF3.5sp1 for a project, and I've been working around many of its problems... as such, my entity partial classes have a lot of logic in them for change-tracking and whatnot.  Obviously, I'd like to factor this logic out into a common base class, but of course all my objects must derive from EntityObject.  Is it possible to tell them to derive from some class of my own invention (which would actually likely derive from EntityObject themselves)?

I'd rather avoid editing the EDMX file unless the changes will be safe on entity-model-update, since I'm still making changes to the database schema in this early state of my project.


Also, is there any good workaround for the fact that the change isn't tracked when you change EntityReference.EntityKey?

CLR Inside Out: What's New in the .NET Framework 4 Base Class Library


Just about everyone who uses Microsoft .NET uses the Base Class Libraries (BCL).When we make the BCL better, almost every managed developer benefits. This column will focus on the new additions to the BCL in .NET 4 beta 1.

Justin Van Patten

MSDN Magazine September 2009

CLR Inside Out: Base Class Library Performance Tips and Tricks


The common language runtime (CLR) sits at the very heart of managed code. Indeed, it is the heart of managed code, so to understand managed code you need to understand the CLR.

Kit George

MSDN Magazine January 2006

Serial Comm: Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications


Out-of-the-box, the only way of coding RS232 serial communications applications in the .NET environment is to import the outdated and somewhat limited MSComm ActiveX control. This article describes the development of a lean, multithreaded, and modern RS232 base class library in C# managed code. The library uses Platform Invocation Services to interact with the Win32 API directly. Application programmers can use the library from any .NET language through inheritance; the article explores examples written in C# and Visual Basic .NET.

John Hind

MSDN Magazine October 2002

Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy


Windows services are applications that run outside of any particular user context in Windows NT, Windows 2000, or Windows XP. The creation of services used to require expert coding skills and generally required C or C++. Visual Studio .NET now makes it easy for you to create a Windows service, whether you're writing code in C++, C#, or Visual Basic. You can also write a Windows service in any other language that targets the common language runtime. This article walks you through the creation of a useful Windows service, then demonstrates how to install, test, and debug the service.

Ken Getz

MSDN Magazine December 2001

"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not


I tried to convert a project from ASP.NET 1.1 to 2.0 and found one big problem which stops the whole process.

An .aspx page from the subfolder "admin" includes a user control from the subfolder "common". Both subfolders ("admin" and "common" are in the root).

- admin
-- aspx page
- common
-- user control

The page works well when started from Visual Studio, but when the project is precompiled for deployment, the next error occurs:

"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not compatible with the type of control (ASP.common_webusercontrol_ascx)"

I tried to use "Reference" in the .aspx page, but that doesn't work.

Does anybody know any workaround for this?

override of base class error please help!!!


i would really like to override http keepalives for my webservice and i found some source code that seems promising but i get an error that says

"function GetWebRequest" Cannot be declared override. 


    Protected Overrides Function GetWebRequest(ByVal uri As Uri) As WebRequest
        Dim webRequest = DirectCast(MyBase.GetWebRequest(uri), HttpWebRequest)
        webRequest.KeepAlive = False
        Return webRequest
    End Function

how do i implement this into my serivice and why im i getting this error??? in other words what in hell is the uri that i should be passing into this function.

Any assictance would be greatly appreciated.


BinaryFormatter, SortedSet base class and a few instance variables.

/* This example successfully serializes and deserializes the SortedSet<string> base contents, but all the instance variables show up uninitialized. Here's the output: n1: 0 n2: 0 str: s == "String 1" s == "String 2" s == "String 3" Any ideas? */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.IO; [Serializable] public class MyObject : SortedSet<string> {     public MyObject() : base() { }     protected MyObject(SerializationInfo info, StreamingContext context)         : base(info, context)     {     }     public int n1 = 0;     public int n2 = 0;     public String str = null; } namespace BasicBinarySerializationInheritanceFromSortedSet {     class BasicBinarySerializationInheritenaceFromSortedSetTest     {         static void Main(string[] args)         {             {                 MyObject obj = new MyObject();   &nb

How to update row using Domain Service Class programmatically?

How to update row using Domain Service Class programmatically in Silverlight without bind to any datagrid and other control? Please help.chanmm

How to update row using Domain Service Class programmatically?

How to update row using Domain Service Class programmatically in silverlight without binding to any datagrid and so? Please help.  chanmm

All data in class properties disappear across WCF service

Hi, I have a class that i share betwee silverlight client and wcf service. I populate properties of the class with real data from the client, to be used in the server. I use debugger to step through the code when the call gets to the server, all the data ara gone and are replaced with null. All DateTime value change to 1/1/1001. But if pass primitive types such as int, string, no problem. This is happening only on one machine, but not on ther machine. Can someone tell me what is going on here? Thanks in advance

Can you Serialize a Derived class, cast as it's base?

Can you Serialize a Derived class, cast as it's base? (Using the stock XmlSerializer.Serialize?)   (The overall goal I'm trying to achieve, is I have 1 object, and I need to serialize it in 2 different ways, 1 with full info, one with half info, and I *thought* a base class would be the way to do it)   e.g. I have a base and derived class   [XmlRoot("MyBaseXml" )] public class MyBaseClass { public string baseField = "base" ; } [XmlRoot("MyDerivedXml" )] public class MyDerviedClass : MyBaseClass { public string derivedField = "derived" ; }   I make a new instance of my derived class MyDerviedClass obj = new MyDerivedClass();   And then I have the following serialization method(s)   /// <summary> /// Saves an object to a file /// </summary> /// <param name="obj"> Object to save</param> /// <param name="fileName"> Path to output to</param> public void Serialize(object obj, string fileName) { Type type = obj.GetType(); XmlSerializer xmlSerializer = new XmlSerializer(type); Serialize(obj, fileName, type); } /// <summary> /// Saves an object to a file casting it as a specific type /// </summary> /// <param name="obj"> Object to save</param> /// <param name="fileName"

Base class contructor firing first. why?

Hi,If I create instance of derived class, the code in base class constructor executing first. why is that? any reason?see code belowPublic Class class1 Sub New() Console.WriteLine("1") End Sub End Class Public Class class2 Inherits class1 Sub New() Console.WriteLine("2") End Sub End Class

Single class with service and callback contract

Can a single class implement service and callback contract. Thanks-= JL =-

Is it possible to add a class method to CLR base class like Date?

Hi All, I would like to add a class method like ParseYYYYMMDD to the Date base class. So that I can use the following code. Dim result As Date = Date.ParseYYYYMMDD(dateString) Any idea? Is it possible via extension? Thanks! Regards, AlexAlex Lau from HKSAR
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend