【问题标题】:Cannot parse *.Config file无法解析 *.Config 文件
【发布时间】:2014-03-05 17:08:37
【问题描述】:

在 .NET 4.5 Winforms 应用程序中并使用我得到的 PayPal API 文档中的确切代码:

“无法解析 *.Config 文件。确保您已正确配置 'paypal' 部分。”

我只是发布导致此问题的行: OAuthTokenCredential tokenCredential = new OAuthTokenCredential("xxxxxxxxxxxxxx", "xxxxxxxxxx");

任何想法如何进行?

谢谢

【问题讨论】:

  • 该行不是来自您的配置文件。
  • 正确。它在我的表单代码中。 Winforms 应用程序。
  • 但错误提示无法解析配置文件。看看那里没有意义吗?
  • 史蒂夫,你没有帮助,但谢谢你的尝试。
  • 我很有帮助。你还没有意识到……但你会的。祝你好运!

标签: winforms api config


【解决方案1】:

由于史蒂夫选择了迟钝,为了其他人有这个问题,这里是一个类似问题的链接,它解决了我的问题。可能是我缺乏使用 app.config 文件的经验,但我必须确保将代码作为文件中的第一个条目插入,否则我的 HttpClient 类在启动时失败。

让我走上正确道路的链接: Paypal c# REST API asks for an undocumented configuration section

我的 App.config 文件(在添加 NuGet PayPal REST SDK 包和来自上述链接的解决方案部分后,来自新 VS2013 WinForms 项目的基本 App.config 文件)

正如链接中提到的,aaa、bbb、ccc、ddd 来自您的沙盒帐户配置文件。

<configSections>
    <section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK"/>
</configSections>

<paypal>
    <accounts>
        <account  apiUsername="aaa"
                            apiPassword="bbb"
                applicationId="ccc"
                apiSignature="ddd"/>
    </accounts>
    <settings>
        <add name="mode" value="sandbox"/>
    </settings>
</paypal>

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-07
    • 2011-12-29
    • 2017-05-01
    • 2021-10-06
    • 2019-01-12
    • 2020-10-05
    • 2017-08-17
    • 2017-12-14
    相关资源
    最近更新 更多