1

在 mvc(.net 框架 4.6.2) 中集成 Power bi 时

低于错误。

找不到方法:Void Microsoft.PowerBI.Api.V1.PowerBIClient..ctor(Microsoft.Rest.ServiceClientCredentials, System.Net.Http.DelegatingHandler[])

var credentials = new TokenCredentials(accessKey, "AppKey");

var client = new PowerBIClient(credentials)
{
    BaseUri = new Uri(apiUrl)
};

已安装

Microsoft.PowerBI.Core 1.1.6.17045

Microsoft.Rest.ClientRuntime

微软.PowerBI.Api 1.1.6.17045

堆栈跟踪:

在 DSLUI.Controllers.ReportsController.Index() 在 E:\DM\DSLServices\DSLUI\Controllers\ReportsController.cs:line 53 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute( ControllerBase 控制器,Object[] 参数)在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 参数)在 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult,ActionInvocation innerInvokeState)在 System.Web。 Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters。 <>c__DisplayClass46.b__3f() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker。<>c__DisplayClass33.b__32(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c() 在 System.Web.Mvc。 Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) 在 System.Web .Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult, Controller controller) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1。在 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) 在 System.Web.Mvc.MvcHandler 的 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) 的 End()。 b__5(IAsyncResult asyncResult, ProcessRequestState innerState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1. End() 在 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) 在 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System。 Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,布尔值&完成同步)

任何帮助请..

4

1 回答 1

2

System.Net.Http.dll 引用的问题,我发现这是旧版本 2.xxx

升级到4.0.0.0,那么在web.config中应该如下

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
  </dependentAssembly>

然后我遇到了另一个问题

Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

为此添加

<compilation debug="true" targetFramework="4.6.2">
  <assemblies>     
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />   
  </assemblies>
</compilation>
于 2017-02-20T07:20:03.110 回答