Believe it or not there are some bugs in the subassemblies that ship with Civil 3D. In addition there are some cases in a design where a custom coded subassembly is the best solution. This is especially true when repetitive code is used that doesn’t work well in Subassembly Composer.
To correct any bugs or create your own subassembly a good place to start is using the code that ships with Civil 3D. The code is located at:
C:\Program Files\Autodesk\AutoCAD Civil 3D 2012\Sample\Civil 3D API\C3DStockSubAssemblies
I usually copy the project to a different location. This way you can always get a fresh copy and you move it outside the Window’s UAC. Once open you first must add the correct references. The easiest way to do this is to set the Reference Paths:
Next you might notice a plethora of errors showing up. This is because for some odd reason the programmers of the Subsassemblies, they did not like to declare all of their variables correctly. I guess they don’t believe in treating all warnings as errors. Strangely when you open the solution the check box on the compile tab of the project is set to treat all warnings as errors. Unchecking this box will remove all of the errors back to warnings.
Next if you are using a 64-bit operating system, or not. You’ll want to change the build target type. To do this open the Configuration Manager.
Next select the Active Solution Platform and select the <New… > option. Select AnyCPU from the list and base it on the x64 build.
Next we need to change the target Framework. The setting is set to .NET Framework 2.0. Unfortunately Civil 3D uses .NET Framework 3.5. So go in and change the Target Framework to 3.5.
Now rebuilding the solution and replacing the existing dll with the new one should then compile.