Sometimes, access to PropertySets with ApprenticeServer fails with this exception:
System.Runtime.InteropServices.COMException (0x80004005): Erreur non spécifiée (Exception de HRESULT : 0x80004005 (E_FAIL)) à System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) à Inventor.ApprenticeServerDocument.get_PropertySets()
I'm using the GUID {D5CDD505-2E9C-101B-9397-08002B2CF9AE} to access the user defined properties set. It works most of the time, but sometimes, I've got this error.
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Hi
Could you clarify what you mean by "sometimes" ? Is it dependent on the data that you use, the workflow, ... ?
Without being able to reproduce the issue on our side it is difficult to help you further.
Thank you,
Philippe.
Hi,
Are you using threads by any chance?
That could have unexpected results, e.g.:
http://adndevblog.typepad.com/manufacturing/2014/09/apprentice-in-side-thread.html
Cheers,
I'm using Apprentice in a Vault job handler. The thread appartment state is MTA. The thread is started by the job processor, I'm not sure what I need to do...
Hi,
As pointed out in the article Apprentice does not support multi threading, not even accessing it from a thread other that the main thread is tested/supported.
However, the latter seems to work as long as you are using it from an STA thread.
I guess if you are already in an MTA thread then you could create another one which is STA and only that should use Apprentice.
Did you try that?
Cheers,
I've used your sample project to test properties access. When thumbnail access fail, iProperties does not. Don't you think it is because COM is used for PictureDispToImage conversion?
I guess if you are already in an MTA thread then you could create another one which is STA and only that should use Apprentice.
Did you try that?
Not yet (it's a bit ugly, starting a thread from a BackgroundWorker thread and does I need a message loop?) and in fact, I can not reproduce the issue on my computer, it only arise on the machine of my customer.
A good doc on the subject: https://msdn.microsoft.com/en-us/library/windows/desktop/ms693779(v=vs.85).aspx and also: http://stackoverflow.com/questions/2222365/what-is-a-message-pump
Hi,
The first article seems to talk about how you could write your code depending on the experience you want to provide. Apprentice was not written in a thread safe mode and you cannot change it. You can however write code around it that makes sure that it is only used from a single STA thread at a time.
Also, I think threading issues are like memory issues (e.g. overwriting memory used by other objects): depending on what the exact issue is some of them show up quite consistently while others do not.
In our case the thumbnail access is a consistent issue, while others might not be.
I would try to organize the code in a way that you do not need a message loop in a thread. Once you know what exactly you want to do with a given file, pass all the parameters including the file name to the STA thread that will be using Apprentice, you can wait for this thread from your MTA thread, and once STA thread is finished you can get back the result.
You could also wrap Apprentice in a separate application that would provide a COM or other inter-process communication capable API and use that from your Job Processor code, but that seems even more work.
Cheers,
I already drive an Inventor session in other handlers, so I'm going to use it. As it is out-of-process, it should work. I'm going to post another question to Vault Customization Group. May be someone has already had this kind of problem.
Thanks.