unable to create surfaces using VB.NET

unable to create surfaces using VB.NET

wang890
Collaborator Collaborator
770 Views
4 Replies
Message 1 of 5

unable to create surfaces using VB.NET

wang890
Collaborator
Collaborator
i am converting some code from VBA to VB.NET, the following code paprt will cause error, which worked in VBA:

Dim oTinVolumeSurfaceCreationData As New AeccTinVolumeCreationData

will generate this error:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

in VB.NET.

i can't figure out why. any suggestions? i spend a long time programming the form. if this is the one that's stopping me from succeeding. that'll be really annoying. is it a bug in the civil 3d API?
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
0 Likes
771 Views
4 Replies
Replies (4)
Message 2 of 5

wang890
Collaborator
Collaborator
anybody tried to create a new surface from vb.net?? why can't i initialize a new instance of the creation data??
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
0 Likes
Message 3 of 5

Anonymous
Not applicable
Hi wang890,

I have code that works fine in VB.NET. The big difference I see is that I
use this method to setup the creation data:

Dim oTinVolumeSurfaceCreationData As AeccTinVolumeCreationData

oTinVolumeSurfaceCreationData = New AeccTinVolumeSurfaceCreationData

HTH
Jeff

"wang890" wrote in message news:[email protected]...
anybody tried to create a new surface from vb.net?? why can't i initialize a
new instance of the creation data??
0 Likes
Message 4 of 5

wang890
Collaborator
Collaborator
Hi, Jeff

i tried your way, i still get the corrupt memory problem. i did some research on google and even downloaded the hotfix, still didn't fix it. i am using VB.net 2005 basic and c3d 2008. maybe 2008's better? here's complete code for a button. attached picture as well. maybe some security setting somewhere?

thank you

Bob

Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click

If lvwBase.Items.Count = 0 Or lvwComp.Items.Count = 0 Then Exit Sub

Dim oSurfaces As AeccSurfaces = oAeccDb.Surfaces
Dim oTinVolumeSurface As AeccTinVolumeSurface
Dim oBaseSurface As AeccSurface
Dim oComparisonSurface As AeccSurface
Dim sBaseSurfaceName As String
Dim sComparisonSurfaceName As String

'get the base surface
oBaseSurface = oSurfaces.Item(CInt(lvwBase.Items(0).SubItems(1).Text))
sBaseSurfaceName = oBaseSurface.DisplayName

'get each of the comparison surfaces and create tin volume surface, and name based on tin volume surface names
Dim oTinVolumeSurfaceCreationData As AeccTinVolumeCreationData
oTinVolumeSurfaceCreationData = New AeccTinVolumeCreationData

For i As Integer = 0 To lvwComp.Items.Count - 1
oComparisonSurface = oSurfaces.Item(CInt(lvwComp.Items(i).SubItems(1).Text))
sComparisonSurfaceName = oComparisonSurface.DisplayName

'Create tin Volume Surface Creation Data

oTinVolumeSurfaceCreationData.BaseLayer = "SURFACE-VG-" & sComparisonSurfaceName
oTinVolumeSurfaceCreationData.BaseSurface = oBaseSurface
oTinVolumeSurfaceCreationData.ComparisonSurface = oComparisonSurface
oTinVolumeSurfaceCreationData.Description = "Tin Volume Surface created from " & sBaseSurfaceName _
& " (base)" & " and " & sComparisonSurfaceName & " (comparison)"
oTinVolumeSurfaceCreationData.Layer = "SURFACE-VG-" & sComparisonSurfaceName
oTinVolumeSurfaceCreationData.Name = txtPrefix.Text & sComparisonSurfaceName
oTinVolumeSurfaceCreationData.Style = cmbStyles.Text

oTinVolumeSurface = oAeccDb.Surfaces.AddTinSurface(oTinVolumeSurfaceCreationData)
Next
Update_Volume_Surface()
End Sub
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hi Bob,
My code was created in VB.NET 2005 Express Edition, so it's not a 2005 vs
2008 issue. I don't see anything glaringly wrong with this portion of your
code.

If you'd like to send me your project, I'll have a look at it for you. You
can contact me at: miff AT sonic DOT net
You can ask others, I don't share code or drawings entrusted to me which I
offer to help with.

Jeff


"wang890" wrote in message news:[email protected]...
Hi, Jeff

i tried your way, i still get the corrupt memory problem. i did some
research on google and even downloaded the hotfix, still didn't fix it. i am
using VB.net 2005 basic and c3d 2008. maybe 2008's better? here's complete
code for a button. attached picture as well. maybe some security setting
somewhere?

thank you

Bob
0 Likes