I follow XCad instructions to try to open a customize command manager tab in SolidWorks.
However, it keeps popping up an error:
“The expression .Substring(0, 4) cannot be evaluated. Index and length must refer to a location within the string. Parameter name: length”
As no line and code for this error, I have totally no idea how to solve it.
Could anyone help?
@Ryan, do you have this during the compilation, i.e. in the Visual Studio or at runtime? I can see Substring(0, X) is used once in the code to extract the version of the file which I believe is not the case here.
And it is also used in the project targets to extract the current version of the framework. And I believe later one is the case. If so, please make sure you are using either .NET Framework or .NET Core , .NET 5 is not supported yet as per this ticket. My recommendation to use .NET Framework instead of .NET Core for SOLIDWORKS add-ins.
@artem
I am using Visual Studio to code (Community 2015)
using .NET Framework 4.6.1 currently,
and these are the Nuget package I have downloaded and used as Reference
Ah, I see. Visual Studio 2015 is quite old and I believe has a different structure (could you please attach this .csproj file here so I can inspect it) - I am using 2019 Community. I think you can make it work in a slightly different way:
Unload the project and edit content (alternatively just open your *.csproj file in the notepad)
I try using 2019 at the beginning but not even work in recording VSTA macro in SolidWorks…
I tested the VSTA macro recording after a long time of not using it and it opened up in VS2015 automatically.
Solidworks 2021 + VS2015 + VS2019 installed
I also had installed Microsoft Visual Studio 2005 Tools for Applications which was opening the macro in older times (VSTA 2.0 only if I remember correctly). VS2015 took over apparently.
Solidworks 2020 does the same: opening the macro in VS2015. But I had to switch on the option:
Enable VSTA Version 3.0.
Maybe you should do that also in 2019 ?
Hi @Eddy , here is the case and that’s why I am using VS 2015:
what I just done is uninstall VS 2015 and SolidWorks
then have a clean installation for VS 2019 and the VSTA Tools
then install SolidWorks 2019 again
and click the Enable VSTA Version 3.0.
for this question I have already tested different methods and finally find a forum reply that work, but requiring me to use VS2015: 3DEXPERIENCE Platform (3ds.com)