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

时间:2017-02-17 15:33:27

标签: c# .net asp.net-mvc powerbi powerbi-embedded

将Power bi集成在mvc(.net框架工作4.6.2)

低于错误。

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

at

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

Microsoft.PowerBI.Api 1.1.6.17045

堆栈跟踪:

位于E:\ DM \ DSLServices \ DSLUI \ Controllers \ ReportsController.cs中的DSLUI.Controllers.ReportsController.Index():第53行    在lambda_method(Closure,ControllerBase,Object [])    在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, IDictionary 2个参数)    在System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult,ActionInvocation innerInvokeState)    在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.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.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.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.WrappedAsyncResultBase 1.End()    在System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)    在System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)    在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.End()    在System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)    在System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult,Controller controller)    在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.End()    在System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)    在System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)    在System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult,ProcessRequestState innerState)    在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.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 step,Boolean& completedSynchronously)

任何帮助请...

1 个答案:

答案 0 :(得分:2)

System.Net.Http.dll referance问题,我发现这是旧版本2.x.x.x

升级到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>