我的类库无法使用MySql .net连接器建立mysql连接。如果我通过使用类库的命令行控制台应用程序运行它,它可以连接。但是当我使用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)
答案 0 :(得分:1)
cacls "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config"
在命令提示符下将显示该文件的权限/内容。您还需要验证文件上方所有目录的访问权限。