COM Exception 0x8004005

3

I have a C# web service that is calling COM objects to access a FileNet imaging system. The service is occasionally encountering the following error when making a call to the FileNet COM objects:

System.Runtime.InteropServices.COMException (0x80040005): Need to run the object to perform this operation (Exception from HRESULT: 0x80040005 (OLE_E_NOTRUNNING))

Any idea on what this means, or how to troubleshoot it? I could find almost nothing when searching with Google, and my experience with COM is very limited. Thanks.

c#
com
filenet-image-services
asked on Stack Overflow Feb 24, 2010 by Mike K. • edited Feb 6, 2014 by ᄂ ᄀ

2 Answers

2

Unfortunately, that HRESULT is the "Something Went Wrong" error code. I would suggest:

  1. Check the system and application event logs to see if there are any better error messages being logged
  2. Check any application specific error logs for your COM component

If neither of those shed any more light on what is going wrong, you may want to consider adding your COM assembly to a Component Services package. This should let you shut it down and restart it much more easily without having to reboot the system.

Depending on the OS (This is from Windows 7, but most are similar):

  1. Start component services (under Administrative tools, usually)
  2. Drill down to Component Services, Computers, My Computer, COM+ Applications.
  3. Right click to add a new application.
  4. Choose to create an empty application. This will let you pick which COM components you want to run in here.
  5. Give the application a name
  6. If you don't know much about your COM component, I would recommend choosing a Server application to start. This will start it out-of-process for the caller. If this doesn't work (e.g. calls fail and such), remove this application and try again as a library application.
  7. Pick the credentials for the service. Network Service is probably the safest choice (e.g. fewest permissions), but I have no idea what your requirements are. You may need to provide a domain account or LocalSystem if it is accessing hardware or other such things.
  8. Finish out the wizard (you may need to revisit these if you need more control).
  9. Drill into your new Application and find the Components folder.
  10. Right click and choose New Component
  11. If the COM controls are already registered, choose Import components. If not, choose Install Components
  12. Now select the components you care about. Note that it is fairly important to get all the inter-related components into the same application. Otherwise, older COM assemblies are unlikely to work correctly
  13. Finish out the wizard. If you go back to the COM+ Application level of the tree view you should see your new application, with a non-animated icon.

There shouldn't be any changes necessary to the calling code. Make a request to your service and go back to the manager... you should see the icon animate once the COM+ Application starts up. You should also be able to re-start it from here, if you desire.

There are a lot of configuration options around spin-down time and pooling, so that may help you to if you find that the COM DLL only gives issues after a certain period of time, for example.

answered on Stack Overflow Feb 26, 2010 by Ben Von Handorf
0

If the problem is truly intermittent, and sometimes happens on one machine, and sometimes doesn't - you could write your code to trap the error, and have it try again.

If there are machines it never works on, it may be due to some other issue, such as UAC, or the component not being properly installed.

answered on Stack Overflow Feb 25, 2010 by Andy Jacobs

User contributions licensed under CC BY-SA 3.0