0

Config.SenparcWeixinSetting.Items["xxx"]得不到值

微信开发 · donet520 · 查看 3008 次 · 于 2年前

配置了多个小程序 ,Config.SenparcWeixinSetting.Items["xxx"]得不到值
您尚未登录,请:网站登录 or 微信登录
共收到 3 条回复
0

Senparc 2年前

光这些代码代码应该是对的,除了Items下面的,第一层的都能正确读取吗?
另外看一下appsettings.json 的文件编码是否有问题,你试试看英文。如果可以的话可能是编码不对,中文读出来乱码了。

0

donet520 2年前

版本是.NET 7.0.5,不知道注册的对不对

注册
//启用微信配置(一句代码)
           var registerService = app.UseSenparcWeixin(app.Environment,
               null /* 不为 null 则覆盖 appsettings  中的 SenpacSetting 配置*/,
               null /* 不为 null 则覆盖 appsettings  中的 SenpacWeixinSetting 配置*/,
               register => { /* CO2NET 全局配置 */ },
               (register, weixinSetting) =>
               {
                   //注册小程序信息(可以执行多次,注册多个小程序)
                   register.RegisterWxOpenAccount(weixinSetting, "第一个小程序");
                   register.RegisterWxOpenAccount(weixinSetting.Items["第二个小程序"], "第二个小程序");

                   //注册微信支付(可以执行多次,注册多个微信支付)
                   register.RegisterTenpayApiV3(weixinSetting, "第一个小程序");//记录到同一个 SenparcWeixinSettingItem 对象中
                   register.RegisterTenpayApiV3(weixinSetting.Items["第二个小程序"], "第二个小程序");//记录到同一个 SenparcWeixinSettingItem 对象中
               });


配置
//Senparc.Weixin SDK 设置
 "SenparcWeixinSetting": {
   //以下为 Senparc.Weixin 的 SenparcWeixinSetting 微信配置
   //注意:所有的字符串值都可能被用于字典索引,因此请勿留空字符串(但可以根据需要,删除对应的整条设置)!

   //微信全局
   "IsDebug": true,

   //以下不使用的参数可以删除,key 修改后将会失效

   //小程序
   "WxOpenAppId": "1111111111111111111",
   "WxOpenAppSecret": "1111111111111111111",
   "WxOpenToken": "1111111111111111111",
   "WxOpenEncodingAESKey": "1111111111111111111",

   //微信支付V3
   "TenPayV3_AppId": "1111111111111111111",
   "TenPayV3_AppSecret": "1111111111111111111",
   "TenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
   "TenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
   "TenPayV3_MchId": "1111111111111111111",
   "TenPayV3_SubMchId": "#{TenPayV3_SubMchId}#", //子商户,没有可留空
   "TenPayV3_Key": "#{TenPayV3_Key}#",
   "TenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#", //https://YourDomainName/TenpayApiV3/PayNotifyUrl
   "TenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#", //(新)证书私钥
   "TenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#", //(新)证书序列号
   "TenPayV3_ApiV3Key": "#{TenPayV3_APIv3Key}#", //(新)APIv3 密钥

   //以下Items中的内容根据实际情况使用
   //Items 下面可以添加任意多个公众号、小程序、企业微信、微信支付(V2/V3)、开放平台的信息
   "Items": {
     "第二个小程序": {
       //公众号
       "WxOpenAppId": "2222222222222222222222222",
       "WxOpenAppSecret": "2222222222222222222222222",
       "WxOpenToken": "2222222222222222222222222",
       "WxOpenEncodingAESKey": "2222222222222222222222222",

       //微信支付V3(新版),略
       "TenPayV3_AppId": "2222222222222222222222222",
       "TenPayV3_AppSecret": "2222222222222222222222222",
       "TenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
       "TenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
       "TenPayV3_MchId": "2222222222222222222222222",
       "TenPayV3_SubMchId": "#{TenPayV3_SubMchId}#", //子商户,没有可留空
       "TenPayV3_Key": "#{TenPayV3_Key}#",
       "TenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#", //https://YourDomainName/TenpayApiV3/PayNotifyUrl
       "TenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#", //(新)证书私钥
       "TenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#", //(新)证书序列号
       "TenPayV3_ApiV3Key": "#{TenPayV3_APIv3Key}#" //(新)APIv3 密钥
     }
   }
 }


获取得时候是空的
var config1 = Config.SenparcWeixinSetting.Items["第一个小程序"];
var config2 = Config.SenparcWeixinSetting.Items["第二个小程序"];
{
"config1": {
"itemKey": "第一个小程序",
"token": null,
"encodingAESKey": null,
"weixinAppId": null,
"weixinAppSecret": null,
"wxOpenAppId": null,
"wxOpenAppSecret": null,
"wxOpenToken": null,
"wxOpenEncodingAESKey": null,
"weixinCorpId": null,
"weixinCorpAgentId": null,
"weixinCorpSecret": null,
"weixinCorpToken": null,
"weixinCorpEncodingAESKey": null,
"weixinPay_PartnerId": null,
"weixinPay_Key": null,
"weixinPay_AppId": null,
"weixinPay_AppKey": null,
"weixinPay_TenpayNotify": null,
"tenPayV3_MchId": "1111111111111111111",
"tenPayV3_SubMchId": "#{TenPayV3_SubMchId}#",
"tenPayV3_Key": "#{TenPayV3_Key}#",
"tenPayV3_CertPath": null,
"tenPayV3_CertSecret": null,
"tenPayV3_AppId": "1111111111111111111",
"tenPayV3_AppSecret": "1111111111111111111",
"tenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
"tenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
"tenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#",
"tenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#",
"tenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#",
"tenPayV3_APIv3Key": "#{TenPayV3_APIv3Key}#",
"tenPayV3_WxOpenTenpayNotify": null,
"component_Appid": null,
"component_Secret": null,
"component_Token": null,
"component_EncodingAESKey": null,
"agentUrl": null,
"agentToken": null,
"senparcWechatAgentKey": null
},
"config2": {
"itemKey": "第二个小程序",
"token": null,
"encodingAESKey": null,
"weixinAppId": null,
"weixinAppSecret": null,
"wxOpenAppId": null,
"wxOpenAppSecret": null,
"wxOpenToken": null,
"wxOpenEncodingAESKey": null,
"weixinCorpId": null,
"weixinCorpAgentId": null,
"weixinCorpSecret": null,
"weixinCorpToken": null,
"weixinCorpEncodingAESKey": null,
"weixinPay_PartnerId": null,
"weixinPay_Key": null,
"weixinPay_AppId": null,
"weixinPay_AppKey": null,
"weixinPay_TenpayNotify": null,
"tenPayV3_MchId": null,
"tenPayV3_SubMchId": null,
"tenPayV3_Key": null,
"tenPayV3_CertPath": null,
"tenPayV3_CertSecret": null,
"tenPayV3_AppId": null,
"tenPayV3_AppSecret": null,
"tenPayV3_SubAppId": null,
"tenPayV3_SubAppSecret": null,
"tenPayV3_TenpayNotify": null,
"tenPayV3_PrivateKey": null,
"tenPayV3_SerialNumber": null,
"tenPayV3_APIv3Key": null,
"tenPayV3_WxOpenTenpayNotify": null,
"component_Appid": null,
"component_Secret": null,
"component_Token": null,
"component_EncodingAESKey": null,
"agentUrl": null,
"agentToken": null,
"senparcWechatAgentKey": null
}
}

0

Senparc 2年前

请问您是如何配置的?包括 .NET 版本?


热门话题 更多 >>

v3微信支付验签失败,v3各参数均已填写

macong 5 个回复 • 查看 1709 次 • 127天前

微信支付验签报错

taowendi 3 个回复 • 查看 2058 次 • 57天前

Program.cs中启用UseSenparcWeixin报错

xxxx96923 3 个回复 • 查看 1516 次 • 57天前

Senparc.Weixin.MP不支持.net9吗

xxxx96923 2 个回复 • 查看 1069 次 • 57天前

WeixinTrace.SendCustomLog无法记录日志

mabelp 2 个回复 • 查看 845 次 • 57天前

怎么在program中注册多个微信支付

好好好好 2 个回复 • 查看 1405 次 • 147天前

V3微信支付 参数都没问题

yangzhijian 1 个回复 • 查看 208 次 • 8天前

盛派是放弃对接企业微信了吗?

ccccc_wt 1 个回复 • 查看 800 次 • 57天前

微信支付配置文件

zhangsan2025 1 个回复 • 查看 800 次 • 51天前

.Net8不存在

dawei 1 个回复 • 查看 460 次 • 26天前

微信后台验证报下面的错误

laowu 1 个回复 • 查看 1591 次 • 103天前

获取企业审批模板selector控件选项key错误

YYDS 1 个回复 • 查看 1647 次 • 135天前

v3支付方式只有JSAPI 支付和Native 支付两种吗?

txdingdong 1 个回复 • 查看 1459 次 • 172天前

服务商申请小微商户的几个方法怎么实现?

yangzj 0 个回复 • 查看 243 次 • 26天前

个人信息
QQ群
  • 1群:300313885 (2000人群 已满)
  • 2群(公众号):293958349 Senparc.Weixin.MPSDK 2群
  • 3群:342319110 (2000人群 已满)
  • 4群:372212092 (500人群 已满)
  • 5群:377815480 (1000人群 已满)
  • 6群:425898825 (1000人群 已满)
  • 7群:482942254 (500人群 已满)
  • 8群:106230270 (500人群 已满)
  • 9群:539061281 (500人群 已满)
  • 10群(分布式缓存):246860933 Senparc.Weixin.Cache SDK 10群
  • 11群:553198593 (500人群 已满)
  • 12群(小程序):108830388 (2000人群 已满)
  • 13群(开放平台):183424136 (500人群 已满)
  • 14群(视频学员):588231256 Senparc.Weixin SDK 14群
  • 15群(综合):289181996 (500人群 已满)
  • 16群(开放平台):860626938 (500人群 已满)
  • 17群(小程序):770615466 [17群 开放平台]SenparcSDK
  • NCF 技术交流群:147054579 SCF 开发交流群
微信开发宝典:《微信开发深度解析》

由 Senparc.Weixin SDK 作者耗时两年完成的微信开发图书《微信开发深度解析:公众号、小程序高效开发秘籍》已经出版!

历经2年精心雕琢,难得的“理论 + 实战案例 + 趟坑经验”总结,
从需求分析、策划,到账号申请、验证,再到全面的 API 及开发工具,
覆盖所有开发微信公众号(含订阅号、服务号和小程序)所需关键技能!

视频教程:《微信公众号+小程序快速开发》

由盛派课堂(盛派旗下独立教育品牌)制作,《微信开发深度解析》作者苏震巍先生主讲的《微信公众号+小程序快速开发》视频课程开课啦!

课程采用“理论+实战”的教学形式,结合部分《微信开发深度解析》内容,独立于书本,包含了更多的操作演示和案例展示,帮助大家从多个维度学习微信开发以及.NET开发过程中的诸多技巧。
课程包含两大部分:
1. 微信开发基础技能
2. 公众号及小程序案例实战
共计60课时,配有番外篇,目前视频已在网易云课堂上线。