can't debug the codes copied from a macro project

Hi everyone,

I am trying to develop a C# addin to automatically generate a part. The first step I did is to record the part generation process, and I can get C# codes from there. Then, I copied these codes to my project, modified it to be a general one and built it.

Everything looks good, except that I can only test the addin function by starting SolidWorks from desktop, but not from "running it" from Visual Studio... If I run it from VS in debug mode, the following error pops up.

However, it works well if I run SolidWorks from desktop.

Can anyone please let me know the solution?

Thanks

Tony

SolidworksApi macros