I cannot make sense of this behavior so I'm not sure how to ask for help. While debugging, I'm calling ChangeState3 from an IEdmFile13. During that process something is causing PDM to try to register our other task add-in, again. I say again because the task add-in has already been registered. The program I'm debugging has nothing to do with the task add-in; they're not even in the same solution and I'm not using any of the my libraries (other classes) from the add-in solution. The call does succeed though because the file does change state. I did this a bunch of times.
The dialog I get is:
followed by this one"

- image.png (7.68 KiB) Viewed 11245 times
If you look closely you can see it has a '3' at the end of the GUID number because it downloaded the add-in files again when I debug my project (that has nothing to do with pdm task add-in project)
I can change state through the vault view manually just fine.
This is a console app, not windows Form.
The transition(s) I'm calling in code do have some actions to set variables, but no execute task actions so they are not calling our task add-in.
I thought there was something wrong with my SW and PDM installation on my development machine (a VBox guest) so I did a clean uninstall and reinstalled SW and PDM from our admin image, like normal. Of course added the vault view back etc.
After doing that I noticed that my Projects' reference to the EPDM.Interop.epdm was broken. Turns out previous installation of PDM was not in the same place as it is now in the C:\ProgramFiles\ directory, so I updated the reference to the new installation location and rebuilt. I don't know if that has anything to do with it.
After fresh installation same behavior.
Just guessing now, I rebuilt my home brew task add-in project and updated the add-in files through the PDM Admin Tool. Then exited from pdm and restarted explorer.exe on my development machine. That made no difference again.
I cannot understand why calling ChangeState3 while debugging one project is causing PDM to try to register some other task add-in that's already registered. Clearly I have something screwed up but I'm lost as to what or how to find it.
Side note, I tried ChangeState() (not 2 or 3) but that always throws an exception that the state ID doesn't exist, whether I pass the state id as an int or the name as a string. I know that state id and name are good because they are in the dbo.Status table with Enabled = 1. ChangeState3 handles the state id just fine. Well, except PDM throws this darned error. There's about 50k part numbers in my list to work through and using the API Search call for each one is slow so I really don't want to sit here and click "OK" the whole time this runs.
I don't recall if I ever tried simply calling ChangeState3 all by itself in a test program. I'll go write a simple console app for that to see if it is the same.

about ready to quit and start
I'm open to any suggestions at this point.
by bnemec » Thu Oct 21, 2021 2:03 pm
AlexB wrote: ↑Thu Oct 21, 2021 11:06 am
I have always heard that this is something to check within a program when using the PDM or Solidworks API, but I don't know what issues it causes if you don't. Now I know.
Thanks for letting us know some symptoms and the resolution to your issue. I'm sure it will help others.
I don't understand all that goes on, but the 64bit dlls are registered/loaded differently than the 32bit. I don't know if or how some add-ins register both the 32 and 64 bit. I THINK that this was a problem only for my add-in because I had a 32bit standalone trying to register a dll that was 64bit only so it was going off the rails somewhere in that process. Perhaps if my task add-in was compiled for 32bit then my 32 bit stand alone would have been fine. Maybe someone that understands the underlying mechanisms can explain it better for us.
This is one of those "Applied programming concepts" as I call them that are important when working with add-in code but are not specific to any one software's API. I remember reading from Jason Newell about this in the past and I could barely grasp it.
This was a popular topic on the Solid Edge Dev Forum back when ST9 rolled out as it had the big switch to pretty much only 64bit dlls. Bit me three years ago:
https://community.sw.siemens.com/s/ques ... 9-and-2019
You'd think I would learn; but instead, I need a hard reminder every few years I guess.
I do hope this helps others, be nice if they see it before they waste time trouble shooting in the wrong direction like I did/do.
For future ref, if you're having dlls fail to register check this setting for your project properties. It should likely be 64bit only, or "Prefer 32-bit" NOT checked.
image.png
Maybe I should change my signature to mention this. May as well add something about [STAThread] too.
Go to full post