System.NullReferenceException: Object reference not set to an instance of an object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zvikorn
    New Member
    • Jul 2006
    • 2

    System.NullReferenceException: Object reference not set to an instance of an object

    Hi,

    I'm trying to call a function written in a dll file, from ASP.NET 1.1 web application.

    Part of code in global.asax:

    <%@ Import namespace="WPPS YSTEMDLLLib" %>

    Sub Application_OnS tart()

    Dim Value As Object

    Application("WP PSystem") = new WPPSystem() <-- the name of the class

    Res = Application("Wp pSystem").INISt rGet("WPP", "StartPage" , "", Value, "c:\wpp.ini ", 0)

    I get the following error:

    System.NullRefe renceException: Object reference not set to an instance of an object

    Application("WP PSystem") is not null. It does get the instance of object.

    Any idea whats wrong?

    Thanks a lot,

    zvikorn
  • Enyi
    New Member
    • Jul 2006
    • 38

    #2
    It could possibly be an object inside your referenced dll that hasn't been initialised. Maybe there is another method which you need to call first to initialise an object, in the dll before the method you call on the line where the error occurs in your code.

    Comment

    • dotnet
      New Member
      • Jul 2006
      • 22

      #3
      you have not created a object of your WPPSystem class.

      you can do it as

      Dim objWPPSystem as WPPSystem






      Regards
      Nitin Mittal
      http://www.dotnetdonke y.com

      Comment

      • zvikorn
        New Member
        • Jul 2006
        • 2

        #4
        Originally posted by Enyi
        It could possibly be an object inside your referenced dll that hasn't been initialised. Maybe there is another method which you need to call first to initialise an object, in the dll before the method you call on the line where the error occurs in your code.

        10x for your reply.
        There is no other method to call before.
        What I'm thinking is, one of the parameters has to be called by reference. in the dll its defined: byRef myStr.
        How can I write it in the calling method? I cant just pass the parameter itself.

        Comment

        • Enyi
          New Member
          • Jul 2006
          • 38

          #5
          Did you try what dotnet said?

          Yes you can just pass the parameter itself. I'm not 100% sure about the difference between ByVal and ByRef. Try Googling for them :)

          Comment

          • aotter
            New Member
            • Aug 2006
            • 1

            #6
            did you guys figure this out? I'm having exactely the same problem calling an old C++ dll from C#, it's also a function that passes a parameter by reference. I can call all the other functions in the dll that don't pass any values by reference just fine!!!

            Comment

            Working...