将AdWordsApi密钥添加到App.config

时间:2017-06-06 15:18:54

标签: vb.net google-adwords

我使用VB开发Windows表单应用程序。我的软件将连接到SQL数据库和Google Adwords API。问题是当我尝试在App.config文件中添加Adwords Api的密钥时出现以下错误:“配置系统无法初始化:无法识别AdWordsApi配置部分”。我已经阅读了一些关于填充我的Appconfig文件的例子,但似乎没有任何工作。你能帮我知道正确的方法吗?我在这里留下我的App.config文件

<?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXX">
            <section name="ReporteExcel.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXX" requirePermission="false"/>
        </sectionGroup>
    </configSections>

    <AdWordsApi>
        <add key="MaskCredentials" value="true"/>
        <add key="EnableSoapExtension" value="true"/>
        <add key="EnableGzipCompression" value="true"/>
        <add key="IncludeUtilitiesInUserAgent" value="true"/>
        <add key="ProxyServer" value=""/>
        <add key="ProxyUser" value=""/>
        <add key="ProxyPassword" value=""/>
        <add key="ProxyDomain" value=""/>
        <add key="DeveloperToken" value="XXXXXXXXXXXXXXXXX"/>
        <add key="GeneralClientCustomerId" value="XXX-XXX-XXXX"/>
        <add key="CanalDigitalClientCustomerId" value="XXX-XXX-XXXX"/>
        <add key="BanamexClientCustomerId" value="XXX-XXX-XXXX"/>
        <add key="AuthorizationMethod" value="OAuth2"/>
        <add key="OAuth2ClientId" value="XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"/>
        <add key="OAuth2ClientSecret" value="XXXXXXXXXXXXXX-XXXXXXX"/>
        <add key="OAuth2RefreshToken" value="1/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXX-X"/>
        <add key="WebClientCustomerId" value="XXX-XXX-XXXX"/>
        <add key="SkipReportHeader" value="true"/>
        <add key="SkipReportSummary" value="true"/>
        <add key="SkipColumnHeader" value="false"/>
    </AdWordsApi>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
    <applicationSettings>
        <ReporteExcel.My.MySettings>
            <setting name="sqlConnectionStr" serializeAs="String">
                <value>Data Source=192.168.2.1;Initial Catalog=CATALOG;User ID=ADMIN;Password=ADMIN;</value>
            </setting>
        </ReporteExcel.My.MySettings>
    </applicationSettings>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Google.AdWords" publicKeyToken="XXXXXXXXXXX" culture="neutral"/>
                <bindingRedirect oldVersion="18.33.0.0" newVersion="18.34.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Google.Ads.Common" publicKeyToken="XXXXXXXXXXXXXX" culture="neutral"/>
                <bindingRedirect oldVersion="3.17.0.0" newVersion="3.18.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

1 个答案:

答案 0 :(得分:0)

在读取文件时,configSections充当文件的目录 尝试以下更改,看看它是否会识别它。 taken from here

    <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXX">
                <section name="ReporteExcel.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXX" requirePermission="false"/>
            </sectionGroup>
            <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler"/>     
 </configSections>