vendredi 26 février 2016

Unit Test fail with HRESULT: 0x80070005 (E_ACCESSDENIED) on TFS

I have an Outlook Add in where I am using Microsoft.Office.Interop.Outlook.Storageitem to save my settings.

Most of my tests access the settings to set or get the configuration for contacting the server.

On my local machine all of the tests are running fine. But when I check in my project into TFS and run the tests there all of them fail with the Error:

System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

The error occurs when the test is calling the following codeline.

Folder inbox = (Folder) new Microsoft.Office.Interop.Outlook.Application().GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderInbox);

I asume that the error appears because the test tries to access an Application of Outlook and does not have the permission.

  • Outlook is instaled on the Windows Server 2012 where TFS is running.
  • Also Outlook was started once with having no Mailaccount configured. (The test runs fine when i start it manually on a machine with a Outlook with no Mailaccount configured.)
  • The C:\Windows\SysWOW64\config\systemprofile\Desktop folder exists.
  • I already have set all permissions for the user NETWORK SERVICE in Controlpanel->Administrative tools->Component Services->computers-> myComputer->DCOM Config->Microsoft Outlook enter image description here

I also found this question which has no answer to my problem.

Are there any other steps i could do to give my tests access to run the tests sucessfully?

OR

Is there a way to define which user runst the tests for TFS and give him administrative rights?

Aucun commentaire:

Enregistrer un commentaire