This is my first post at this forum. Usually i find a solution but this time i can not.
This issue is not for forums like stackoverflow because it strongly relates to autodesk api.
It could be a post at autodesk autocad/civil 3d developer forums but autodesk personnel no longer participate and i think this issue is quite unique for other members to deal with.
I did a research using the 'net user control issue' but...
So here i am.
Each time i make a new program i have to do all the UI from scratch. So i decided to create UserControls.
For example a user control to get the corridors of a dwg and put them in a dropdown list in a combo box.
So i created one. Next to compiling the component is automatically added at the toolbox.
Trying to add it to a form i get a failure message and it is automatically removed from the toolbox.
I found out that if i add the lines below everything works fine
Public currentCRDRobj As Autodesk.Civil.DatabaseServices.Corridor
Public ListOfCorridorNames As New List(Of String)
I also tried entering an Alignment object and it worked fine.
But if i add one of the lines below i have the issue i mentioned
Public currentCRDRid As Autodesk.AutoCAD.DatabaseServices.ObjectId = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null
Public ListOfCorridorObjects As new List(Of Autodesk.Civil.DatabaseServices.Corridor)
So there is no issue with civil 3d custom objects such as corridor or alignment but there is an issue when they are set in a ListOf.
Also the foundation of each program, assigning an autodesk custom object ID to a variable, leads to an issue.
I attach a simple VisualStudio 2017-Civil 3D 2018 vb.net solution containing both UserControl and Form to test zipped files.
The base solution file is at 'CorridorBaselineStationsAddByFile' folder.
Load this solution.
The paths are related to my pc folders so project reloading is a must.
Project : autoCAD_Civil3D_2018_r2_UserControls
contains the user control
UserControl1.vb
Project : TKV_CorridorBaselineStationsAddByFile
contains the form to drop the user control
frmCorridorBaselineStationsAddByFile.vb
Project build order is not an issue.
Recompile solution. It will succeed.
Set the focus at the 'frmCorridorBaselineStationsAddByFile.vb [Design] tab.
A new folder named 'autoCAD_Civil3D_2018_r2_UserControls Components' will be created at the toolbox.
It will contain the 'UserControl1' component.
Now drag and drop this component at the form.
Everything works fine.
Now set focus to 'UserControl1.vb'.
The lines that cause the issues are set to comment state.
Uncomment 'Public ListOfCorridorObjects by removing the '.
Recompile solution and set focus to 'frmCorridorBaselineStationsAddByFile.vb [Design] tab.
Voila !
Select Ignore and Continue, then Yes, and...UserControl1 is gone although it exists at the 'UserControl1.Designer.vb'.
This message should not show. Whose fault is it ? Mine ? Autodesk's ? Microsoft's ? Mix of ?
Now reset focus to 'UserControl1.vb'.
Uncomment 'Public currentCRDRid.
Recompile solution and set focus to 'frmCorridorBaselineStationsAddByFile.vb [Design] tab.
Select Ignore and Continue, then Yes.
A different error message shows up.
Now go to Toolbox. The component still exists. Try drag and drop it.
Oops. It is gone.
Any ideas ? Am i doing something wrong ?
Should i try posting also at the autodesk autocad/civil 3D dev forums ?