Learn how to stay in touch with CodeStack latest updates about SOLIDWORKS API, C#, Visual Basic, DevOps and software development tutorials and tips & trick. Never miss the releases of new useful macros or applications to enhance your SOLIDWORKS experience.
SOLIDWORKS VSTA macro (C# or VB.NET) cannot be run and the Cannot Open error is displayed
Unlike VBA macros VSTA macros are compiled in-process applications based on .NET Framework.
The main difference is source code and binaries (deliverables) are separate elements.
In order to run the macro it is required to compile it. .NET applications are using interops to communicate with COM objects (such as SOLIDWORKS).
Which means that it is required to have interops copied locally to run the macro.
- Copy all files in the output (bin) directory as the deliverables. You may exclude .pdb and .xml files as those are used for debugging and documentation purposes
- If the macro was supplied without this files try to create new VSTA macro and copy missing files
- If macro (or zip archive) was downloaded from web. Make sure that files are not blocked as it might cause the issue.