Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17878

Trying to embed a PowerBI report in a WebSharper Client Server F# application

$
0
0

I started from the downloaded PowerBIEmbedded_AppOwnsData C# razor demo, which works as expected. Then I tried to do the same starting with a WebSharper project, but didn't have success so far. The problem occurs when I try to istantiate a PowerBIClient object.

First the working C#

 

...
// Create a user password cradentials.
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
// Create a Power BI Client object. It will be used to call Power BI APIs.
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
...   

And now the F# code that doesn't work:

...
let credential = new UserPasswordCredential(Username, Password)
let authenticationContext = new AuthenticationContext(AuthorityUrl)
let authenticationResult = 
    authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential)
    |> Async.AwaitTask |> Async.RunSynchronously
let tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer")
let client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)
...

The project compiles without errors, but at runtime it generates an exception; When the let client = ... is executed I get:

 

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, 
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly 
reference. (Exception from HRESULT: 0x80131040) 

=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, 
PublicKeyToken=30ad4fe6b2a6aeed
 (Fully-specified)
LOG: Appbase = file:///C:/Root/Project/NCF/NCF.BPP1/
LOG: Initial PrivatePath = C:\Root\Project\NCF\NCF.BPP1\bin
Calling assembly : Microsoft.Rest.ClientRuntime, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: 
C:\Root\Project\NCF\NCF.BPP1\web.config
LOG: Using host configuration file: 
\\aunpmfps1\mydocs$\Franco.Tiveron\IISExpress\config\aspnet.config
LOG: Using machine configuration file from 
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, 
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL 
file:///C:/Users/franco.tiveron/AppData/Local/Temp/Temporary ASP.NET 
Files/vs/6323d2e3/834678d6/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL 
file:///C:/Users/franco.tiveron/AppData/Local/Temp/Temporary ASP.NET 
Files/vs/6323d2e3/834678d6/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL 
file:///C:/Root/Project/NCF/NCF.BPP1/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing 
terminated.

Please help. Thank you in advance.


Viewing all articles
Browse latest Browse all 17878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>