GetActiveObject COM Error

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello All,

 

I am creating a SolidEdge drawing through windows service.

the "Marshal.GetActiveObject("SolidEdge.Application") or CreateObject("SolidEdge.Application")"

is not working.

 

It gives the below error:

Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

 

The same code when written as Windows Application works well with no issues.

 

Not sure what is the issue.

I also changed the permission of SolidEdge Assembly in Component Services and gave permission to everyone.

 

Please help.

 

Thanks 

Shruthi

 

5 REPLIES

Re: GetActiveObject COM Error

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I recently covered this topic in my Solid Edge Automation via IIS blog post. Even though you're using a Windows Service and my blog is about IIS, the concepts are the same. I'm assuming you're starting Solid Edge as your UI user and trying to GetActiveObject() inside of the Windows Service. That will never work. Your service will have to start Solid Edge and manage its lifetime.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: GetActiveObject COM Error

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello Jason,

 

Thank you for your reply.

I watched your video on IIS.

 

According to that I changed account type of Windows Service Installer to "LocalSystem".

 

But this did not resolve the error.

 

I am getting the same exception again.

 

Re: GetActiveObject COM Error

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Are you creating the instance of Solid Edge from your service or are you trying to GetActiveObject() to an instance of Solid Edge that you started from clicking a shortcut? GetActiveObject() from a service will not connect to an instance of Solid Edge that was started by a UI user. Note that when you create an instance of Solid Edge from a service, you cannot visually see the application window.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: GetActiveObject COM Error

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Not sure if you're still having a problem but wanted to let you know that I've got it on my todo list to look at this and create a video if I come up with anything.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: GetActiveObject COM Error

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello Jason,

 

As you suggested, GetActiveObject gives error but CreateObject works fine.

 

I was waiting for SolidEdge to open but your suggestions helped. Its working fine now.

 

Thank you very much for the immediate response.