【问题标题】:c# - probing privatePath is not workingc# - 探测 privatePath 不起作用
【发布时间】:2016-04-26 12:11:18
【问题描述】:

在我正在使用的 app.config 中

<configuration>
<configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section name="SMSGateway.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
</configSections>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <probing privatePath="OracleLibs" />
</assemblyBinding>
</runtime>
</configuration>

在 OracleLibs 子文件夹中加载 dll 但运行程序时出现错误:

OracleConnection 错误:System.TypeInitializationException:“Oracle.DataAccess.Client.OracleConnection”的类型初始化程序引发了异常。 ---> System.DllNotFoundException:无法加载 DLL 'OraOps12.dll':找不到指定的模块。 (HRESULT 异常:0x8007007E)

任何人都想解决这个问题。谢谢

【问题讨论】:

  • 我在这个话题中找到了答案:stackoverflow.com/questions/1892492/…var dllDirectory = @"C:/some/path"; Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory)

标签: c# database oracle


【解决方案1】:

首先,您引用的是 .dll 吗?

其次,这是否解决了您的问题? Oracle.DataAccess still try to access oraops12.dll after uninstall

第三,这是否解决了您的问题? Unable to load DLL “OraOps10.dll”

【讨论】:

  • 如果我将 dll 放在根文件夹中,程序就可以工作。但我想放在一个子文件夹中,以便更有条理。我的机器上没有 oracle 客户端。在这个项目中,我使用的是第三个库
  • @QuangTrườngNguyễn 您是否尝试(在解决方案资源管理器中)右键单击“参考”,选择“添加参考”,单击“浏览”,然后导航到所需位置的 .dll?
  • @Quang Trường Nguyễn,我正在尝试实现相同的目标,即在根文件夹之外组织 dll,但是当我这样做时,exe 找不到它们。我正在使用调用 .NET COM Interop dll 的 C++ exe。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-07
  • 1970-01-01
  • 2020-11-01
  • 2021-02-25
  • 1970-01-01
  • 2021-11-03
  • 1970-01-01
相关资源
最近更新 更多