I'm interfacing with SolidWorks using C#.
I'm on Visual Studio 2017, latest release (15.7.3). The project references the SolidWorks .tlb files like the documentation says to do. On those references, I set "Embed Interop Types" to false, which allows me to see the type of the objects I'm dealing with when debugging, and look at any public properties etc.
For example, if I'm expecting a FeatureManager, it'll show up as FeatureManagerClass.
However, half of them still say System.__ComObject, like SldWorks or ModelDoc2, even though I can see SldWorksClass and ModelDoc2Class in the Object Browser.
When I run code analysis on the project, it rebuilds, and ~30 warnings will show up saying:
Processing COM reference 'SldWorks' from path "..." At least one of the arguments for "..." cannot be marshaled by the runtime marshaler.
or
Interface "..." is marked as [dual], but does not derive from IDispatch. It will be converted as an IUnknown-derived interface.
I don't know if these are separate issues. Just wondering if I can get all the types to show up properly.
I ran into this problem using VS 2015. In my case I was able to see the com objects types in the debugger by enabling the option "Use managed compatibility mode"
In visual studio if you open tools >> Options and then debugging >> General make sure the option "Use Managed Compatibility Mode" is checked on.
This should show com objects as their proper types in the debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With