MySqlConnection Open не удалось, доступ запрещен даже с олицетворением

Моей библиотеке классов не удалось установить соединение mysql с помощью соединителя MySql .net. Он может подключиться, если я запущу его через консольное приложение командной строки, которое использует библиотеку классов. Но это не удается, когда я использую PHP COM для загрузки/запуска сборки .net. В библиотеке классов есть код олицетворения для олицетворения пользователя. Для тестирования я выдаю себя за свою учетную запись.

Глядя на трассировку стека. Какие учетные данные необходимы для доступа к C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config? Каков правильный код для олицетворения в сборке .NET (он также поддерживает COM)?

2011/08/17 10:11:52.653 AM - The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.
2011/08/17 10:11:52.653 AM -    at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)
2011/08/17 10:11:52.653 AM - Configuration system failed to initialize
2011/08/17 10:11:52.653 AM -    at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)
2011/08/17 10:11:52.965 AM - System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Access is denied.
 (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config) ---> System.Security.SecurityException: Access is denied.

   at System.Security.Principal.WindowsImpersonationContext.Undo()
   at System.Security.Principal.WindowsImpersonationContext.Dispose(Boolean disposing)
   at System.Security.Principal.WindowsImpersonationContext.Dispose()
   at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
The Zone of the assembly that failed was:
MyComputer
   --- End of inner exception stack trace ---
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   --- End of inner exception stack trace ---
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
   at System.Diagnostics.TraceSource.Initialize()
   at System.Diagnostics.TraceSource.get_Switch()
   at System.Transactions.Diagnostics.DiagnosticTrace..cctor()
   --- End of inner exception stack trace ---
   at System.Transactions.Transaction.get_Current()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at MineForums.Miner.Process(Int32 forumId, String mineDirectory)

person dan_l    schedule 17.08.2011    source источник


Ответы (1)


cacls "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config" в командной строке покажет, кто/что имеет права доступа к этому файлу. Вы также хотите проверить права доступа для всех каталогов над файлом.

person Marc B    schedule 17.08.2011