System.Data.OracleClient.OracleConnection 引发类型初始值设定项异常
我想就我遇到的问题寻求帮助。我在网站内运行一项很长的任务。由于处理该任务需要一些时间,因此我决定更改结构。不久,现在我从网站调用一个 exe 并监视该过程。在我的开发环境中一切都很好。但是当我尝试在我的产品环境中运行 exe 时,我收到以下异常消息。我使用 System.Data.OracleClient 连接到 Oracle 数据库。
The type initializer for 'System.Data.OracleClient.OracleConnection' threw an exception.
当我从网站调用 exe 时会发生这种情况。我创建了一个 winforms 应用程序来测试 exe。如果我从 winforms 应用程序调用 exe(与从网站调用的方式相同),一切都会正常。
我在网上搜索了异常。我发现了 2 个建议。
1-) 不同版本的 Oracle 客户端: 这就是我创建测试 winforms 应用程序的原因。一切顺利。所以我不认为 Oracle 客户端是问题所在,除非我遗漏了一些东西。
2-) 32位/64位操作系统问题:我最初是针对32位环境编译exe的。我的产品环境是64位。所以我尝试以 64 位为目标进行编译,但得到了相同的异常。另外,32 位 exe 在我的 winforms 测试应用程序中运行没有任何问题。另外,我的开发环境也是 64 位,但我没有遇到异常。
任何想法将不胜感激...
编辑:我找不到类型初始值设定项异常的解决方案。其实我没有时间去深究。所以我所做的是调用一个 winforms exe 并模拟它的按钮单击来调用实际的 exe。我不喜欢这个解决方案,但我必须继续前进。我不再收到 OracleConnection 异常。
I would like to ask help for a problem that I am facing. I was running a long task within a website. Because it was taking some time to process the task, I decided to change the structure. Shortly, now I am calling an exe from the website and monitoring the process. All is fine on my development environment. But when I try to run the exe on my prod environment, I get the following exception message. I use System.Data.OracleClient to connect to Oracle database.
The type initializer for 'System.Data.OracleClient.OracleConnection' threw an exception.
This happens when I call the exe from the website. I created a winforms app to test the exe. And if I call the exe from my winforms app (in the same way that I call from the website) everything works fine.
I searched the exception online. There were 2 suggestions I found.
1-) Different version of Oracle Client : This is why I created the test winforms app. It ran all fine. So I don't think Oracle client is the issue unless I'm missing something.
2-) 32-bit/64-bit OS issue : I initially compiled the exe targeting 32 bit environment. And my prod environment is 64 bit. So I tried to compile targetting 64 bit but got the same exception. Plus, 32-bit exe runs without any problems with my winforms test application. Also my development environment is 64bit as well, but I don't get the exception there.
Any ideas will be appreciated...
EDIT : I couldn't find a solution to type initializer exception. Actually I didn't have time to dig into it. So what I did instead is to call a winforms exe and simulating it's button click to call the actual exe. I didn't like the solution but I had to move on. I am no more getting the OracleConnection exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论