vs2008连接Oracle10G出错

zzengxy 2012-05-12 01:19:43
问题是这样的,我新建一个winform用同样的连接字符串,没有报错,但在我的这个项目就会报错,十会不解
这是我们连接字符串
MessageBox.Show("1111");
string zzzz = @"Data Source=test;Persist Security Info=True;User ID=yp;Password=yp;Unicode=True";
using (OracleConnection conn = new OracleConnection(zzzz))
{
conn.Open();;
MessageBox.Show("sdfsdf");
}
这应该是没问题的,新建项目用这个是没有报错的。就是不明白了OracleClient我也引用了,下南是报错信息,求高手解答



未处理 System.TypeInitializationException
Message="“System.Data.OracleClient.OracleConnection”的类型初始值设定项引发异常。"
Source="System.Data.OracleClient"
TypeName="System.Data.OracleClient.OracleConnection"
StackTrace:
在 System.Data.OracleClient.OracleConnection..ctor(String connectionString)
在 opdoctor.Form1.button1_Click(Object sender, EventArgs e) 位置 d:\我的文档\Visual Studio 2008\Projects\opdoctor\opdoctor\Form1.cs:行号 23
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 opdoctor.Program.Main() 位置 d:\我的文档\Visual Studio 2008\Projects\opdoctor\opdoctor\Program.cs:行号 17
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeInitializationException
Message="“System.Data.OracleClient.OracleConnectionFactory”的类型初始值设定项引发异常。"
Source="System.Data.OracleClient"
TypeName="System.Data.OracleClient.OracleConnectionFactory"
StackTrace:
在 System.Data.OracleClient.OracleConnection..cctor()
InnerException: System.TypeInitializationException
Message="“System.Data.OracleClient.OraclePerformanceCounters”的类型初始值设定项引发异常。"
Source="System.Data.OracleClient"
TypeName="System.Data.OracleClient.OraclePerformanceCounters"
StackTrace:
在 System.Data.OracleClient.OracleConnectionFactory..ctor()
在 System.Data.OracleClient.OracleConnectionFactory..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
Message="配置系统未能初始化"
Source="System.Configuration"
BareMessage="配置系统未能初始化"
Line=0
StackTrace:
在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
在 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
在 System.Configuration.ConfigurationManager.GetSection(String sectionName)
在 System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
在 System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
在 System.Diagnostics.DiagnosticsConfiguration.Initialize()
在 System.Diagnostics.Switch.InitializeConfigSettings()
在 System.Diagnostics.Switch.InitializeWithStatus()
在 System.Diagnostics.Switch.get_SwitchSetting()
在 System.Diagnostics.TraceSwitch.get_Level()
在 System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
在 System.Data.OracleClient.OraclePerformanceCounters..ctor()
在 System.Data.OracleClient.OraclePerformanceCounters..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
Message="无法识别的配置节 add。 (d:\\我的文档\\Visual Studio 2008\\Projects\\opdoctor\\opdoctor\\bin\\Debug\\opdoctor.vshost.exe.Config line 3)"
Source="System.Configuration"
BareMessage="无法识别的配置节 add。"
Filename="d:\\我的文档\\Visual Studio 2008\\Projects\\opdoctor\\opdoctor\\bin\\Debug\\opdoctor.vshost.exe.Config"
Line=3
StackTrace:
在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
InnerException:
...全文
291 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanguojin 2012-07-01
  • 打赏
  • 举报
回复
遇到同样的问题,调试下无法访问oracle数据库,打包程序却可以访问,求解决
zzengxy 2012-05-12
  • 打赏
  • 举报
回复
这是对的,没有问题,我用vs新建一个项目,复制这段代码,都没有出现问题的
[Quote=引用 2 楼 的回复:]

你的连接串是对的吗
引用 1 楼 的回复:

string zzzz = @"Data Source=test;Persist Security Info=True;User ID=yp;Password=yp;Unicode=True";
using (OracleConnection conn = new OracleConnection(zzzz))//在这里设断点调试又……
[/Quote]
我爱白富美 2012-05-12
  • 打赏
  • 举报
回复
你的连接串是对的吗
[Quote=引用 1 楼 的回复:]

string zzzz = @"Data Source=test;Persist Security Info=True;User ID=yp;Password=yp;Unicode=True";
using (OracleConnection conn = new OracleConnection(zzzz))//在这里设断点调试又没错哦
{
conn.Open();;//……
[/Quote]
zzengxy 2012-05-12
  • 打赏
  • 举报
回复
string zzzz = @"Data Source=test;Persist Security Info=True;User ID=yp;Password=yp;Unicode=True";
using (OracleConnection conn = new OracleConnection(zzzz))//在这里设断点调试又没错哦
{
conn.Open();;//这里设断点就报错了,说初始化失败,好奇怪啊
MessageBox.Show("sdfsdf");
}

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧