.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calling COM interop from another thread

4 REPLIES 4
Reply
Message 1 of 5
aligili
990 Views, 4 Replies

Calling COM interop from another thread

Hi,

 

I have developoed a .Net dll(Autocad plugin) in which it tries to create a task on another thread.

The task lauches another instance of Autocad via COM interop and sends commands. But this throws exceptions at different points like SendCommand(...). 

I know .Net APIs are not multithread, but  here no .Net APIs are called in this new thread, and all COM object methods

are being called in the same thread(the newly created one) that the new Autocad instance is created(via COM).

 

Dose anyone know what the problem is ?

 

Many thanks

4 REPLIES 4
Message 2 of 5
Alexander.Rivilis
in reply to: aligili


aligili wrote:

...The task lauches another instance of Autocad via COM interop and sends commands. But this throws exceptions at different points like SendCommand(...). ...


What exceptions are throwing?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 5
aligili
in reply to: Alexander.Rivilis

Thanks for your reply,

 

this exception is thrown :

the message filter indicated that the application is busy
HRESULT: (RPC_E_SERVICECALL_RETYLATER)

acAcadApp.BeginCommand += new _DAcadApplicationEvents_BeginCommandEventHandler(acSeperateApp_BeginCommand);
acAcadApp.EndCommand += new _DAcadApplicationEvents_EndCommandEventHandler(acSeperateApp_EndCommand);
acAcadApp.BeginOpen += new _DAcadApplicationEvents_BeginOpenEventHandler(acSeperateApp_BeginOpen);
acAcadApp.EndOpen += new _DAcadApplicationEvents_EndOpenEventHandler(acSeperateApp_EndOpen);

 

either at

-acAcadDoc.SendCommand(cmd);

or at the time of registering application events :

-AcadApplication acAcadApp = new AcadApplication();

if (acAcadApp == null) return false;

acAcadApp.BeginCommand += new _DAcadApplicationEvents_BeginCommandEventHandler(acSeperateApp_BeginCommand);
acAcadApp.EndCommand += new _DAcadApplicationEvents_EndCommandEventHandler(acSeperateApp_EndCommand);
acAcadApp.BeginOpen += new _DAcadApplicationEvents_BeginOpenEventHandler(acSeperateApp_BeginOpen);
acAcadApp.EndOpen += new _DAcadApplicationEvents_EndOpenEventHandler(acSeperateApp_EndOpen);

acAcadApp.Visible = false;

 

I also removed registering the events for the COM object but did not change anything.

 

Message 4 of 5
Alexander.Rivilis
in reply to: aligili


@aligili wrote:

Thanks for your reply,

 

this exception is thrown :

the message filter indicated that the application is busy
HRESULT: (RPC_E_SERVICECALL_RETYLATER)


Maybe RPC_E_SERVERCALL_RETRYLATER ?

Try this solution: http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-b...

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 5
aligili
in reply to: Alexander.Rivilis

Thanks Alexander,

 

The class has already implemented the interface. but thanks for your reply.

 

 

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost