I saw the same question you posted earlier in Autodesk forum, but hesitated to respond, because I really do not what does it mean by "Unable to persist a PaletteSet from session to session". Do you mean:
In current session your PaletteSet is open, user may change its size/dock state. Then user close and restart AutoCAD, when open the PaletteSet, its size/dock state does not remain as it was when it was open last time?
If the PaletteSet was assigned an unchanged GUID (such as your code shows), AutoCAD should be able to persist the PaletteSet's state between sessions. Besides the size/dock state, AutoCAD also should remember whether the PaletteSet was visible or not in previous session.
I suspect the real issue with you is that when you restart AutoCAD session, you saw AutoCAD calls your "BAD" command automatically and then reports "Unknown command" (so, it is real BAD command
).This is due to following reasons:
1. When you close AutoCAD with your PaletteSet open, AutoCAD does persists the PaletteSet's state (because the PaletteSet has a fixed GUID). When AutoCAD session starts again, it remembers that your PaletteSet was open previously, if the PaletteSet is created with constructor PaletteSet(string name, Guid id) or PaletteSet(string name, string cmd, Guid id);
2. There constructors with 2 arguments is a bit strange: the first string argument is both the PaletteSet name and the command that is used to open it.
So, in your case, if you want your PaletteSet behaces like AutoCAD built-in ones (Layer Manager, Design Center...), which has a command specified in the constructor, so that AutoCAD can automatically opens it if it was open in previous session, you need to preload your DLL or make your DLL load on demand, so that the command that opens your PaletteSet is available when AutoCAD tries open it automatically.
If you do not really need to let AutoCAD opens your PaletteSet just because it was open in previous session, you can specify a blank string in the PaletteSet constructor, which had been pointed out by someone's reply to your post in Autodesk discussion forum:
ps=New PalettSet("", New Guid(....))
or
ps=New PaletteSet("My BAD Palette Set","", New Guid(...))
This way, AutoCAD will not try to open your PaletteSet automatically upon its starts.