AnsweredAssumed Answered

Add .NET Controls to SOLIDWORKS using an Add-in Example (VB.NET)

Question asked by Derek Eldridge on Mar 18, 2016
Latest reply on Nov 18, 2016 by Derek Eldridge

Please help.

I'm still fairly new to both solidworks API and VB. Please excuse my ignorance, as I'm learning by way of trial by fire.

Using the example @

2016 SOLIDWORKS API Help - Add .NET Controls to SOLIDWORKS using an Add-in Example (VB.NET)

I've followed the instructions and ran into a few Errors and Warnings that I'm not sure how to fix.

  1. In SwAddin.vb
    1. An error showed "}" Expected in the following line:
      1. Dim docTypes As Integer() = New Integer() {swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING), swDocumentTypes_e.swDocPART
      2. Should that be:
      3. Dim docTypes As Integer() = New Integer() {swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING, swDocumentTypes_e.swDocPART}
  2. In WPFControl.g.i.vb
    1. 3 Errors, all the same on lines 44, 53, 72
    2. Error Code: BC31424             
    3. Description: Type 'System.Windows.Markup.IComponentConnector' in assembly 'VBDotNetControlsDemo, Version=1.0.5921.19308, Culture=neutral, PublicKeyToken=null' has been forwarded to assembly 'System.Xaml, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Either a reference to 'System.Xaml, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' is missing from your project or the type 'System.Windows.Markup.IComponentConnector' is missing from assembly 'System.Xaml, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.



  • Microsoft Visual Studio Community 2015
  • Solidworks 2016 SP1.0
  • VBDotNetControlsDemo -> Properties -> Application -> Target framework -> Set to .NETFramework 4.6.1
    • (This framework cured some of the other errors I was getting not listed here)

Also, as a side note,

I couldn't enter code in the UserControl1.Designer.vb, and Form1.Designer.vb because they were not listed in the Solution Explorer by that name. For example it shows UserControl1.vb, then under it UserControl1. What I figured out was the Designer file (the .vb), Visual Studio only allowed me to see the visual representation, but not enter code. When right click and selected to view code, it kicked me to the non-".vb" labeled file. As a work around, I opened the file manually with notepad from windows explorer, and pasted the code directly, then saved, and closed notepad. Visual Studio prompted me that the file was updated outside of visual studio, and would I like to reload. Obviously I chose yes. This seemed to work as the visual representation was then updated for the files labeled with ".vb"

If there is another way to enter this code to the Designer files, and/or change the view to a split view like the WPFControl.xaml opens to.