none
object reference not set to an instance of an object - Weird Problem in VB.Net RRS feed

  • Question

  • Hi,

     

    I am having a weird problem. I have a class library called A. dll which has method A().  Then I developed another library called B.dll which are referencing A.dll in it. Then I developed another library called C.dll which are also referencing A.dll in it.

     

    Now the issue is, B.dll managed to call successfully the method A() in A.dll, but C.dll cant call the method A() in A.dll even though referenced correctly. I have removed and add back the reference of A.dll in the C.dll solution file.

     

    When I debug , managed to see, the line calling the method A() in A.dll throwing the error "object reference not set to an instance of an object", but B.dll successfully calling method A() in A.dll.

     

    What am i missing here? Whole day I have been cracking my head.

     

    Thanks and appreciate your help in this matter.

     

    Malini

    Friday, September 30, 2011 5:21 AM

Answers

  • Hi Bharath,

     

    Thanks for the information, but I managed to found the bug, which was causing by a user control which till now, I have no idea why it cause the error and no any error compilation. But when I correct the bug line and rebuild. It solve the issue.

    Thanks to all who have took effort to suggest me and helped me.

     

    Cheers guys...

     

    Malini

    • Marked as answer by lini0103 Saturday, October 1, 2011 2:50 AM
    Saturday, October 1, 2011 2:50 AM

All replies

  • Hi,

    Did you referenced the A.dll in the project C. If not do it.

    Also try to import the A.dll namepace into the project C, like

    Imports A

    After importing ,try to create a object for the A.dll like

    Dim tempObject as a.test -> method in project A;

    Hope it helps.If not post more about the problem.

    Regards,
    A.Murugan

     


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    Friday, September 30, 2011 6:02 AM
  • Hi, Murugan,

     

    Yes Murugan, I have referenced the A.dll in the project of C. and also add the import statement for A.dll namespace.

    During coding also, the intellisense managed to show me the A() method in the A.dll and during building and rebuilding the project also have no any error nor warnings showing up. If right click the method A() which I used in the C project, it is displaying correctly in the  Object browser with the Library and method.

     

    Thanks Murugan

    Need to think what I have done wrong..

     

    Malini

     

     

    Friday, September 30, 2011 6:12 AM
  • Hi,

    Also check in the method, whether any additional parameters needed for the mthod of the Project A, follow the same syntax as you used for calling in project B.

    Let me know whether the issue is resolved or not.
    Regards,

    A.Murugan


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    Friday, September 30, 2011 6:32 AM
  • Hello lini0103,

    I strongly belive that you are not instantiating object of A in C. First Create object of A and then call method.

    A objA = new A();

    objA.A();


    Please mark this post as answer if it solved your problem. Happy Programming!
    Friday, September 30, 2011 6:42 AM
  • Hi Murugan and Avadesh,

     

    My code is sending the correct parameters and initiating correctly..

     

    #Region "Imports"

    Imports A

    #End Region

     

    #Region "Private Variables"

        Private _ParentFormController As A

    #End Region

     

    #Region "Public Property"

        ''' <summary>

        ''' Get/Set Parent Form controller Property

        ''' </summary>

        ''' <value></value>

        ''' <returns></returns>

        ''' <remarks></remarks>

        Public Property ParentFormController() As A

            Get

                Return _ParentFormController

            End Get

            Set(ByVal value As A)

                _ParentFormController = value

            End Set

        End Property

    #End Region

     

        Private Sub DispenseDrugCodeSearchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DispenseDrugCodeSearchButton.Click

            Try

                Dim CodeSearchFormControllerObject As CodeSearchFormController

                MsgBox("1")

                CodeSearchFormControllerObject = _ParentFormController.GetChildForm(_ParentFormController, "CommonSearch")-- This is wear throwing the error in runtime.

    Thanks

     

    Malini  :-(..

    Friday, September 30, 2011 7:22 AM
  • Hi,

    In the following block try this

    Private Sub DispenseDrugCodeSearchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DispenseDrugCodeSearchButton.Click

            Try

                Dim CodeSearchFormControllerObject As New CodeSearchFormController

                MsgBox("1")

                CodeSearchFormControllerObject = _ParentFormController.GetChildForm(_ParentFormController, "CommonSearch")--

    Added the New Keyword for creating CodeSearchFormController, object

    try this and let me know whether it is working

    Regards,

    A.Murugan

     


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    Friday, September 30, 2011 7:50 AM
  • Hi Murugan,

     

    I tried with your method and sad to say, not working. The same error throwing.

    :-(

     

    Malini

    Friday, September 30, 2011 8:11 AM
  • Hi,

    Could you post your entire code here, so that i can check it and let you know , what is the reason for the error.

    Regards,

    A.Murugan


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    Friday, September 30, 2011 9:08 AM
  • Hi Malini,

    It seems '_ParentFormController' object holds NOTHING in it. So Try the below one

    Dim CodeSearchFormControllerObject As  
    CodeSearchFormController
    
    MsgBox("1")
    If _ParentFormController Is Not Nothing Then
          CodeSearchFormControllerObject = _ParentFormController.GetChildForm(_ParentFormController, "CommonSearch")
    Else
         MSGBox("_ParentFormController  Is NOTHING") 
    End If
    
    
    

     


    Thanks and Regards, Bharath S.
    Friday, September 30, 2011 2:47 PM
  • Hi Bharath,

     

    Thanks for the information, but I managed to found the bug, which was causing by a user control which till now, I have no idea why it cause the error and no any error compilation. But when I correct the bug line and rebuild. It solve the issue.

    Thanks to all who have took effort to suggest me and helped me.

     

    Cheers guys...

     

    Malini

    • Marked as answer by lini0103 Saturday, October 1, 2011 2:50 AM
    Saturday, October 1, 2011 2:50 AM