MSTestHacks icon indicating copy to clipboard operation
MSTestHacks copied to clipboard

System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

Open avantida opened this issue 7 years ago • 2 comments

Most team members have no problems running the unit-tests. Yet when I run them on my machine, I get this exception and stacktrace.

  • The Domain.Tests.dll.config file is present

  • The MSTestHacks\debug.txt is present and written to [23-01-18 02:48:37] ------------------ [23-01-18 02:48:37] Starting Execution [23-01-18 02:48:38] Successfully created datasource: Domain.Tests.Core.Request.Aggregate.StatusTests.FinalizationTests.RequestTypes, Iteration Count: 2, Elapsed Time : 00:00:00.3647961

  • The MSTestHacks\RuntimeDataSources folder and files are there and written to

Result StackTrace:

at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections)
   at System.Security.AccessControl.FileSystemSecurity.Persist(String fullPath)
   at System.IO.File.SetAccessControl(String path, FileSecurity fileSecurity)
   at System.Configuration.Internal.WriteFileContext.DuplicateTemplateAttributes(String source, String destination)
   at System.Configuration.Internal.WriteFileContext.DuplicateFileAttributes(String source, String destination)
   at System.Configuration.Internal.WriteFileContext.Complete(String filename, Boolean success)
   at System.Configuration.Internal.InternalConfigHost.StaticWriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.Internal.DelegatingConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.UpdateConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
   at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll)
   at System.Configuration.Configuration.Save(ConfigurationSaveMode saveMode)
   at MSTestHacks.RuntimeDataSource.AttachRuntimeDataSources..cctor() in c:\projects\mstesthacks\MSTestHacks\RuntimeDataSource\AttachRuntimeDataSources.cs:line 163

Result Message: Unable to create instance of class Domain.StatusTests.CancelTests. Error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation..

avantida avatar Jan 23 '18 14:01 avantida

Are you running Visual Studio in administrator mode?

There are a few set access control stuff in there.. im assuming something doesnt have rights to write something..

Thwaitesy avatar Jan 23 '18 21:01 Thwaitesy

Hi, normally I'm not running it in administrator mode. I did so once and then indeed the tests run, but this can not be the desired requirement.

avantida avatar Jan 26 '18 12:01 avantida