Ok. I see the root of your problem. The code was designed to be used as extension methods and as the error states, in vb, extension methods must be defined in modules. Please see below:
Imports System.Runtime.CompilerServices
Imports System.Reflection
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports System.Threading.Tasks
Imports System.IO
''' <summary>
''' Extension Methods
''' </summary>
Public Module ModuleExtensions
''' <summary>
''' saves the current drawing
''' </summary>
''' <param name="db">the database / drawing</param>
''' <remarks>We only had to write this because the autocad api is retarded</remarks>
<Extension()>
Public Sub SaveDamnYou(db As Database)
Dim doc As Document = Nothing
Try
doc = DocumentManager.GetDocument(db)
Catch
'db is in batch mode
End Try
'If we have a document, attempt to call a quick save
If doc IsNot Nothing Then
If doc.IsReadOnly Then
Throw New ArgumentException("Save failed. Drawing is Read-Only.")
Else
Try
doc.Save()
Catch ex As System.Exception
doDBSave(db)
End Try
End If
Else
'If no document, attempt to save the database itself
doDBSave(db)
End If
End Sub
''' <summary>
''' Attempts to save the database to itself, or logs an error if it fails
''' </summary>
''' <param name="db"></param>
''' <remarks></remarks>
Public Sub doDBSave(db As Database)
Try
Dim DwgFilePath As String = db.GetRealFilename
db.SaveAs(DwgFilePath, True, DwgVersion.Current, db.SecurityParameters)
Catch ex As Autodesk.AutoCAD.Runtime.Exception
console.writeline(string.format("Acad Error Status: {0}",ex.ErrorStatus))
Throw
End Try
End Sub
''' <summary>
''' Saves the document via COM
''' </summary>
''' <param name="doc">document to be saved </param>
''' <remarks>Used by the above save routine to allow a lock document to be saved, because the API is SUPER retarded</remarks>
<Extension()>
Public Sub Save(doc As Document)
Dim adoc As Interop.AcadDocument = CType(doc.AcadDocument, Interop.AcadDocument)
'adoc.Save()
adoc.SendCommand("_QSAVE ")
End Sub
''' <summary>
''' gets the real filename of the database. instead of .sv$ filenames
''' </summary>
''' <param name="db">the database / drawing</param>
''' <returns>returns the real filename</returns>
''' <remarks>http://through-the-interface.typepad.com/through_the_interface/2008/03/getting-the-ful.html</remarks...
<Extension()>
Public Function GetRealFilename(db As Database) As String
Dim doc As Document = Nothing
Try
doc = DocumentManager.GetDocument(db)
Catch
'This error indicates that there is no document object
End Try
'is this open in batch mode?
If doc Is Nothing Then
Return db.Filename
Else
Return doc.Name
End If
End Function
End Module Then in your class, you would invoke the save like
<CommandMethod("DOSOMETHING")>
public sub DoSomething()
'...do something here
Autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.database.savedamnyou()
end sub