asp.net - 找不到方法:无效 Microsoft.PowerBI.Api.V2.PowerBIClient..ctor - Power BI Embedded
问题描述
我在使用 Power BI Embedded 时遇到问题。我想在部分视图中嵌入 Power BI 报表。按照指南,我在控制器上创建了这些方法:
public ActionResult Report()
{
credential = new UserCredential(username, passwordPowerBI);
Authorize().Wait();
ReportEmbed myReport = new ReportEmbed();
using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
{
EmbedToken embedToken = client.Reports.GenerateTokenInGroup(groupId, reportID, new GenerateTokenRequest(accessLevel: "View"));
Report report = client.Reports.GetReportInGroup(groupId, reportID);
myReport.reportID = reportID;
myReport.embedURL = report.EmbedUrl;
myReport.embedToken = embedToken.Token;
}
return PartialView(myReport);
}
private static Task Authorize()
{
return Task.Run(async () => {
authenticationResult = null;
tokenCredentials = null;
var authenticationContext = new AuthenticationContext(authorityUrl);
authenticationResult = await authenticationContext.AcquireTokenAsync(resourceUrl, clientID, credential);
if (authenticationResult != null)
{
tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
}
});
}
在视图中,我只是尝试查看我的报告。但是应用程序会出现这个异常:
(抱歉,有些文字是意大利语。“Impossibile trovare il metodo”的意思是“未找到方法”)。
问题是什么?web.config 中缺少某些内容?
解决方案
它看起来像与程序集的版本不匹配。编译时它会找到正确的程序集,而运行时它会加载旧版本的客户端。检查您的部署并确保您使用的是正确的程序集。
推荐阅读
- azure-devops - 从 Azure DevOps Server(OnPrem) 导出所有组/用户
- c# - Extracting a list from a list LINQ
- python - ffmpeg 音频文件裁剪打破较长的音频文件
- python - 如何在不提取的情况下有效地遍历读取所有文件的 7z 存档?
- terraform - 如果我得到 http.StatusNotFound,我应该将 ResourceData 的 ID 设置为什么值?
- mysql - MySQL:有多少不同的客户订购了
- node.js - 如何在另一个数组中的数组中获取值
- javascript - 为建议选择正确的时间控制(onClick)[SAPUI5]
- r - 如何按 ID 列分组并选择应通过 R 中的选择编号删除哪一行?
- linux - Linux - 在核心上不间断地运行线程