Open the assembly in SW and see if components are not missing (Due to component being renamed or moved). If you can see all components, rebuild all configurations, save the assembly and give it a try.
Thanks for the response @nilesh. I understand what you are saying. I’m not trying to get the API call to work but rather understand why it is not working. Opening the document in SW kinda defeats the point really. I can’t even find an API call that tells if I need to open the document in SW and rebuild or not.
Sorry, I probably wasn’t clear. What I meant was to open the assembly manually in SW that you are having issue with to make sure there is no broken reference or all components suppressed.
I created a demo addin couple of years ago where I used GetComponents method and just tested it in SW2021 and seems to be working fine.
Are you having trouble with all assemblies or any particular assembly?
Are you sure. Obviously you have more experience than I, but the “file in use by another process” has probably been my most common issue when dealing with reading files. In this case that error is buried in the API which catches it and just returns null with no informative reason why.
Possibly not related but interesting is how explorer.exe cannot display file details of Solid Edge file if that file is open in Edge.exe. When Solid Edge brought out BiDM (PDM without SQL or file archives) they exposed a bunch of metadata, which were then available as columns that can be added to explorer once SE is installed. Again, if the file is open in SE those properties will not show in explorer and I found that API could not >READ< properties from a file that was open in SE. I’ve learned and forgotten over and over that opening a file for read only operations may very well likely fail if that file is open for edits in another process.
Edt: I wish I knew how NotePad++ can open files that are open for edit by other process. It will even notify when the file on disk has been changed and offer to refresh. To me that is such a polished product to behave that way.
I’m hesitant to remind you to read the remarks section of the help page you linked, it can be taken the wrong way and you could legitimately reply with an image of Captain Obvious. I wouldn’t do it but I’ve lost hours trying to solve something that was warned about in the Remarks section of SW API Help.
This method only returns data for documents created using SOLIDWORKS 2003 (Version 2200) and later. To get the version of a document, use ISwDMDocument::GetVersion.