C#应用程序安装问题
我使用 Visual Studio 2010 和 .NET Framework 4.0 设计了一个 C# 应用程序 它在我的电脑上运行良好。 我使用 DLL 来连接 Oracle DB。 我为我的应用程序创建了一个安装项目来部署它,当我尝试在第二台 PC 上安装该应用程序时,它要求我安装 .NET Framework 客户端,我已经安装了它。 之后,当我尝试运行我的应用程序时,它可以工作,但每次代码尝试从 DLL 调用函数时,它都会引发异常:
System.IO.FileLoadException:无法加载文件或程序集“System.Data.OracleClient,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”或其依赖项之一
我将 DLL 添加到安装文件中,但它没有不工作。 我尝试将此代码添加到我的配置文件中:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="System.Data.OracleClient" fullName="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblyBinding>
</runtime>
但它也不起作用。请提供任何帮助。
I have designed a C# application using Visual Studio 2010 with .NET framework 4.0
and it works well on my PC.
I used an DLL to connect the Oracle DB.
I created a Setup project for my application to deploy it, when I tried to install the application on a second PC, it asked me to install the .NET Framework client, and I have installed it.
After that when I tried to run my application it works but each time the code try to call a function from The DLL it throws an exception:
System.IO.FileLoadException: Could not load file or assembly 'System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies
I added the DLL to the setup file, but it didn't work.
I have tried to add this code to my config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="System.Data.OracleClient" fullName="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblyBinding>
</runtime>
But it didn't work too. Any help, please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现了以下内容:
答案
请检查第一个答案
可能导致此问题的原因是我在第二台 PC 上安装了 .NET4 Client Profile,而不是 .NET4 Full 框架
I have found the following:
Answer
please check the first answer
maybe this problem caused because I have installed the .NET4 Client Profile on the second PC not the .NET4 Full framework
如果您确定 OracleClient-Dll 部署在第二台 PC 上,则问题出在“或其依赖项之一”部分。
至少当我上次(几年前)使用Oracle客户端时,它需要从Oracle安装CD安装额外的Oracle客户端Dll。这是因为 .NET Dll 只是一个调用部署在客户端 PC 上的客户端 Dll 的包装器。
顺便说一句:我们当时的解决方案(因为我们不希望客户安装 Oracle 客户端)是从 DataDirect。它们并不便宜,但它们在托管代码中实现了完整的数据访问,因此您实际上只需将一些 Dll 复制到您的应用程序文件夹中(如果您愿意,也可以复制到 GAC 中)。
If you are sure that the OracleClient-Dll is deployed on the second PC, then the problem is in the "or one of its dependencies" part.
At least when I used the Oracle client the last time (a few years ago) it required the installation of additional Oracle client Dlls from the Oracle installation CDs. That's because the .NET Dll was just a wrapper that called into the client Dlls deployed on the client PC.
BTW: Our solution at that time (because we didn't want our customers to install the Oracle client) was to buy the .NET Dll from DataDirect. They aren't cheap but they implement the complete data access in managed code, so you really need to just copy some Dlls into your application folder (or in the GAC if you want to).