Set entities in OffsetSurfaceFeatureData with VB.NET

Hello everyone,

I've created a code to delete the last face from the selection in an Offset surface.

Based on:

http://help.solidworks.com/2019/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISurfaceOffsetFeatureData~Entities.html

http://help.solidworks.com/2019/english/api/sldworksapi/get_offset_surface_data_example_vb.htm

http://help.solidworks.com/2019/english/api/sldworksapi/Get_Offset_Surface_Data_Example_VBNET.htm

It works fine in VBA:

Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swOffset As SldWorks.SurfaceOffsetFeatureData
Dim boolstatus As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
boolstatus = swModel.Extension.SelectByID2("Surface-Offset1", "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)
Set swFeat = swModel.SelectionManager.GetSelectedObject6(1, -1)
Set swOffset = swFeat.GetDefinition
boolstatus = swOffset.AccessSelections(swModel, Nothing)
Dim vFace As Variant
vFace = swOffset.Entities
ReDim Preserve vFace(UBound(vFace) - 1)
swOffset.Entities = vFace
boolstatus = swFeat.ModifyDefinition(swOffset, swModel, Nothing)
End Sub

But the same in VB.NET doesn't

Private Sub Button1_Click(sender As Object, e As EventArgs)  Handles Button1.Click

Dim swApp As SldWorks
Dim swModel As ModelDoc2
Dim swFeat As Feature
Dim swOffset As SurfaceOffsetFeatureData
Dim boolstatus As Boolean

swApp = GetObject(, "SldWorks.Application")
swModel = swApp.ActiveDoc
swModel.Extension.SelectByID2("Surface-Offset1", "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)
swFeat = swModel.SelectionManager.GetSelectedObject6(1, -1)
swOffset = swFeat.GetDefinition
boolstatus = swOffset.AccessSelections(swModel, Nothing)
Dim vFace As Object
vFace = swOffset.Entities
ReDim Preserve vFace(UBound(vFace) - 1)
swOffset.Entities = vFace
boolstatus = swFeat.ModifyDefinition(swOffset, swModel, Nothing)

End Sub

I can see that vFace has been correctly redim and is populated with the correct faces with:

Dim swEnt As Entity
For Each face In vFace
swEnt = face
swEnt.Select4(True, Nothing)
Next

So either the entities are not being set, or the feature is not being modify.

What am I doing wrong?

Thank you for your attention

SolidworksApi/macros