12 Replies Latest reply on Nov 18, 2016 5:28 PM by Elisabeth Daley

    Wrong pointer error when trying to change file variable (EPDM Add-in)

    Craig Sink

      I'm a newbie here with just a basic grasp of vb.net. I'm attempting to create an add-in that changes properties in a variable. I get an error that says "An invalid pointer was supplied to the method." Based on implementation in the examples, I can't understand why it's an issue. Any ideas?

       

      The error:

      invalid pointer.PNG

       

      My Code:

      Dim value As String = "Check"

                  varEnum.SetVar(strVarName, "@", value) 'invalid pointer error here

                  varEnum.Flush()

       

          • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
            Craig Sink

            That didn't do it unfortunately. I'm still getting the error.

              • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                Lee CS Young

                What does the rest of your code look like? This works;

                 

                Dim vaultName As String = "Sandbox"
                Dim vault As EdmVault5Class = New EdmVault5Class()
                vault.LoginAuto(vaultName, 0)
                Dim folder As IEdmFolder5 = Nothing
                Dim file As IEdmFile5 = vault.GetFileFromPath("F:\Sandbox\Test Mirror Project\7654003.SLDDRW", folder)
                Dim varEnum = file.GetEnumeratorVariable()
                Dim varName As String = "Comment"
                Dim value As String = "Test"
                varEnum.SetVar(varName, "@", value, False)
                
                  • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                    Craig Sink

                    This is most of the sub. I'm passing the IEDMFile, FolderID and vault

                     

                    Public Sub SetProperty(ByRef CurrentFile As IEdmFile5, ByVal FolderID As Integer, ByRef Vault As IEdmVault5)
                    
                    
                            Dim Vault2 As IEdmVault7 = Nothing
                            If Vault Is Nothing Then
                                Vault = New EdmVault5Class()
                            End If
                            Try
                                Vault2 = DirectCast(Vault, IEdmVault7)
                                'Login if not already logged in
                                If Not Vault.IsLoggedIn Then
                                    Vault.LoginAuto("EPDM Vault", 0) 'using '0' as the handle key; originally used Me.Handle.ToInt64()
                                End If
                    
                    
                                'Get card variables on Currentfile
                                Dim folder As IEdmFolder5 = Nothing
                                Dim varEnum As IEdmEnumeratorVariable5
                                Dim strVarName As String = "Check References"
                                Dim file As IEdmFile5 = Nothing
                                Dim FilePath As String = ""
                                FilePath = CurrentFile.GetLocalPath(FolderID)
                                file = Vault2.GetFileFromPath(FilePath, folder)
                                'Check if file is locked, 
                                If Not file.IsLocked Then
                                    'lock file
                                    file.LockFile(FolderID, 0, CInt(EdmLockFlag.EdmLock_Simple))
                                End If
                    
                    
                                'set variable
                                varEnum = file.GetEnumeratorVariable(FilePath)
                                Dim value As String = "Check"
                                varEnum.SetVar(strVarName, "@", value, False) 'invalid pointer error
                                varEnum.Flush() 'flush method to "close" file after variable update
                    
                      • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                        Lee CS Young

                        A couple of things;

                         

                        You're passing an IEdmFile5 reference to the sub, so there's no need to create another reference. (file). Same goes with the vault. Here's your code cleaned up a bit.

                         

                        I also changed the IEdmEnumeratorVariable5 to IEdmEnumeratorVariable8 to use CloseFile.

                         

                        Public Sub SetProperty(ByRef CurrentFile As IEdmFile5, ByVal FolderID As Integer, ByRef Vault As IEdmVault5)
                                If Vault Is Nothing Then
                                    Vault = New EdmVault5Class()
                                End If
                                Try
                        
                                    'Login if not already logged in 
                                    If Not Vault.IsLoggedIn Then
                                        Vault.LoginAuto("EPDM Vault", 0) 'using '0' as the handle key; originally used Me.Handle.ToInt64() 
                                    End If
                        
                                    'Get card variables on Currentfile 
                                    Dim varEnum As IEdmEnumeratorVariable8
                                    Dim strVarName As String = "Check References"
                        
                                    Dim FilePath As String = ""
                                    FilePath = CurrentFile.GetLocalPath(FolderID)
                        
                                    If Not CurrentFile.IsLocked Then
                                        'lock file 
                                        CurrentFile.LockFile(FolderID, 0, CInt(EdmLockFlag.EdmLock_Simple))
                                    End If
                                    'set variable 
                                    varEnum = CurrentFile.GetEnumeratorVariable(FilePath)
                                    Dim value As String = "Check"
                                    varEnum.SetVar(strVarName, "@", value, False) 'invalid pointer error 
                                    varEnum.Flush() 'flush method to "close" file after variable update 
                                    !varEnum.CloseFile(True)
                                Catch Ex As Exception
                                    Console.WriteLine(Ex.Message)
                                End Try
                            End Sub
                        
                      • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                        Craig Sink

                        Well now I feel silly. I couldn't get the code to work, tried 20 times. Tried it again this morning and it's working fine. So I'm not quite sure when or what the fix was.

                         

                        I do have a question though. What is EdmVault5Class? I can't find that in the help and the examples use EdmVault5().

                         

                         

                  • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                    Eddie Pellegrin

                    I'm not using any code, but I get the "Invalid Pointer error" while checking in a file. Any suggestions?

                    • Re: Wrong pointer error when trying to change file variable (EPDM Add-in)
                      Elisabeth Daley

                      Bump.  I have a similar script (C#) trying to update a version-free variable, but I get the 'invalid pointer supplied to the method' error on the SetVar command.  I'm using IEdmEnumeratorVariable8, and have tried setting the 'Embed Interop Types' to False for the EPDM.Interop.epdm reference in Visual Studio.  The script checks the file out before attempting to set the variable.  If anybody has any other ideas, I'd really appreciate it; I've been tearing my hair out over this.

                       

                      Side note: since what I'm trying to update is a version-free variable, I'd prefer not to check the file out at all, but I get other errors if I try it.