MOSS 2007 Checkout



  • Checkout


  • For those of us with no idea what that picture is meant to be (like me), some text from you would be helpful...



  • The error says "this file must be checked out first" but the command which generated the error is the command to check out the file.



  • Heh.  Reminds me of VB6's similar error: When you tried to execute

    Dim SomeThing As AnObject
    SomeThing = New AnObject

    It would tell you that "Object variable or with block not set", meaning that SomeThing = Nothing.  Well of course it does!  That's why I'm setting it to a New AnObject!



  • could it that that you can't check out item.File because item needs to be checked out?  I've never used SQL so I'm just guessing.



  • @Albatross said:

    Heh.  Reminds me of VB6's similar error: When you tried to execute

    Dim SomeThing As AnObject
    SomeThing = New AnObject

    It would tell you that "Object variable or with block not set", meaning that SomeThing = Nothing.  Well of course it does!  That's why I'm setting it to a New AnObject!

     This is a WTF only until you know that there is something called "Default Property" in VB6. Practically what happens is that VB is trying to call AnObject.[Default] (or whatever) method, since you have forgot to use Set keyword.

     This causes indeed lots of head banging if you have to write both vb6 & vb.net, since in .net you do not have to Set object variables.
     



  • @sirhegel said:

    @Albatross said:

    Heh.  Reminds me of VB6's similar error: When you tried to execute

    Dim SomeThing As AnObject
    SomeThing = New AnObject

    It would tell you that "Object variable or with block not set", meaning that SomeThing = Nothing.  Well of course it does!  That's why I'm setting it to a New AnObject!

     This is a WTF only until you know that there is something called "Default Property" in VB6. Practically what happens is that VB is trying to call AnObject.[Default] (or whatever) method, since you have forgot to use Set keyword.

     This causes indeed lots of head banging if you have to write both vb6 & vb.net, since in .net you do not have to Set object variables.
     

    Even if there is no default property, you have to remember that NEW actually runs code in the constructor.  This can happen in VB.Old, C, and all .Net languages. The problem with this is that declaration is fine as it just reserves the memory, instantiation on the other hand can try to create other objects or whatever.  You never know what the object is trying to do under the hood.  So all your NEWs should be considered error prone, wrap then in a Try Catch (or vb's On error).

    This is just one reason why I always have my declaration and instantiation on two separate lines rather then put them all on one. 



  • Try/Catch on New

    @KattMan said:

    Even if there is no default property, you have to remember that NEW actually runs code in the constructor.  This can happen in VB.Old, C, and all .Net languages. The problem with this is that declaration is fine as it just reserves the memory, instantiation on the other hand can try to create other objects or whatever.  You never know what the object is trying to do under the hood.  So all your NEWs should be considered error prone, wrap then in a Try Catch (or vb's On error).

    This is just one reason why I always have my declaration and instantiation on two separate lines rather then put them all on one. 

     What you are suggesting sounds dangerously close to this coding style:

    Dim builder As StringBuilder
    Try
        builder = New StringBuilder
    Catch ex As Exception
        'Error occured
    End Try

    ...

    builder.Append("String")

    If your code looks anything like this please stop.  It hides the original (helpful) exception and replaces it with either undefined behavior or a null reference exception somewhere else.  If you are not sure if the constructor can throw an exception, read the code/documentation.  Putting Try/Catches around random parts of your code because they may be "error prone" does not work.  If there is a specific exception that you want to handle then by all means use a catch, but otherwise you should be letting the exception pass back to the calling function.


Log in to reply