Hi there,
I have a problem with adding a custom menu item using .Net API.
Here is a SolidWorksPerformance.log file fragment:
Here is my code:
string[] images = null;
string image16path = @"C:\Program Files\AddInInstallFolder\MenuItemIcon16.png";
if (File.Exists(image16path ))
images = new string[] { image16path };
var subMenus = frame?.GetSubMenus((int)docType, "&File") as string[];
if (subMenus == null)
return;
var index = 0;
if (subMenus.Contains("Pac&k and Go..."))
index = Array.IndexOf(subMenus, "Pac&k and Go...") + 1;
else
index = subMenus.Length;
swApp.AddMenuItem5((int) docType, cookie, "MyMenuItem@&File", index,
nameof(CallBackMethod) + \$"({MY_COMMAND_ID})", string.Empty, string.Empty, images);
On another machine, this code is working well, but I have a crash running this on my machine, right after swApp.AddMenuItem5 call (I am using Solidworks 2018).
What can be possible reasons causing Access Violation Exception?
Any help would be very appreciated.
Thanks!
SolidworksApi/macros