Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

E_FAIL on PropertySets access

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
FRFR1426
527 Views, 7 Replies

E_FAIL on PropertySets access

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.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
7 REPLIES 7
Message 2 of 8
philippe.leefsma
in reply to: FRFR1426

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 8
adam.nagy
in reply to: FRFR1426

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,



Adam Nagy
Autodesk Platform Services
Message 4 of 8
FRFR1426
in reply to: adam.nagy

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...

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 5 of 8
adam.nagy
in reply to: FRFR1426

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, 



Adam Nagy
Autodesk Platform Services
Message 6 of 8
FRFR1426
in reply to: adam.nagy

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

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 7 of 8
adam.nagy
in reply to: FRFR1426

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,

 

 

 

 

 



Adam Nagy
Autodesk Platform Services
Message 8 of 8
FRFR1426
in reply to: adam.nagy

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.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report