problem in vb.net VSS automation

when i created and automated add method in C# sharp I did not have this problem and was able to add the desired file to the project. I have a problem with using interfaces in vb.net and creating an instance of an object. can anyone help. this is the last piece of code, when i get it to work Im home free. any help may gain me some weekend free time :-) thanks -JP

here is the error that i am getting

System.NullReferenceException: Object reference not set to an instance of an object.
at DBConnectionLib.DBConnectionLib.VSSDomain.addItem(String parentProject, String itemPath)

and here is the code in question:

Function addItem(ByVal parentProject As String, ByVal itemPath As String) As String Implements VSSIFace.addItem

Dim instance As IVSSItem = vssDB.VSSItem(parentProject, False)

Dim retVal As VSSItem

Try

Console.WriteLine("VSSDomain.addItem")

retVal = vssDB.VSSItem(parentProject, False)

retVal.Add(itemPath, "ok", 0)

Catch ex As Exception

Dim writer As New StreamWriter("vssAddFileErr.txt")

writer.WriteLine("Error in vss add file :")

writer.WriteLine(ex)

writer.WriteLine(ex.StackTrace)

writer.Close()

Return "err"

Throw New Exception(ex.ToString & "" & ex.StackTrace.ToString)

End Try

Return ""

End Function




Answer this question

problem in vb.net VSS automation

  • fuzzfoot

    Your missing a instance of an object somewhere.

    Example - if you have a class called FOO and you say

    Dim x as foo

    and try and use x you'll probably generate this error as x is not an instance, it is merely a reference.   If you look at the contents of x at this point it probably is set to nothing.

    Now use

    Dim x as new foo

    and you have instance of class foo called x which you can use.

    My thought is that you need to trace back the line that is causing the problem, look at which variable is not set to an instance, look at its value and ultimately trace it back to where it should have been instantiated,  This is where you will probably find a missing NEW keyword,

     Also  VSS has its own forum

    http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=50&SiteID=1

    which they may provide some additional assistance with


  • problem in vb.net VSS automation