请熟悉 微信Senparc SDK 的帮忙看下json更新自定义菜单

[HttpPost]
public ActionResult CreateMenuFromJson(string fullJson)
{
//TODO:根据"conditionalmenu"判断自定义菜单
string accesstoken = "24_YptJ-vzbfWW3y1qwUUxiTWrE-7XEf0pCEl3YJOzGNyH4PBiB_WkjbbX5HEAxySxoKE2Tluzl3VH9SQMyA5uRAxmA6M6M8OOioAddGYmam10wP3y3eI9KPkI9d5aoZaTBMOJWWqK9FGdChEkfFELhADAYXE";
var apiName = "使用JSON更新";
try
{
GetMenuResultFull resultFull = Newtonsoft.Json.JsonConvert.DeserializeObject(fullJson);

            //重新整理按钮信息
            WxJsonResult result = null;
            IButtonGroupBase buttonGroup = null;

            buttonGroup = CommonAPIs.CommonApi.GetMenuFromJsonResult(resultFull, new ButtonGroup()).menu;
            result = CommonAPIs.CommonApi.CreateMenu(accesstoken, buttonGroup);

            var json = new
            {
                Success = result.errmsg == "ok",
                Message = "菜单更新成功。" + apiName
            };
            return Json(json, new JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });
        }
        catch (Exception ex)
        {
            var json = new { Success = false, Message = string.Format("更新失败:{0}。{1}", ex.Message, apiName) };
            return Json(json, new JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });
        }
    }

            现在是断点到buttonGroup直接跳catch里了 出现ex error CS0103: 当前上下文中不存在名称“ex”

图片说明

图片说明

图片说明

Q:857190695

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问