The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am trying to write a little utility as an external tool.
For now I was just trying to connect to the server and get the database model.
This is the code:
using System;
using System.IO;
using Microsoft.AnalysisServices.Tabular;
namespace PbixTool
{
class Program
{
static void Main(string[] args)
{
var server_port = args[0];
var database_name = args[1];
Console.WriteLine($"Server port: {server_port}, Database: {database_name}");
string ConnectionString = "DataSource=" + server_port;
using (Server server = new Server())
{
try
{
server.Connect(ConnectionString);
var db = server.Databases[database_name];
Console.WriteLine(db.Model);
}
catch (Exception ex)
{
//log exceptions somewhere
Console.WriteLine(ex.ToString());
}
}
Console.WriteLine("Press Enter to close this console window.");
Console.ReadLine();
}
}
}
I registered the built exe as an external tool as explained here: Register an external tool.
When I run the external tool from an empty pbix I don't get any error and I get this output:
Server port: localhost:57713, Database: f19f7559-9afc-45ad-8f3b-a7bc98ac400e
Microsoft.AnalysisServices.Tabular.Model
Press Enter to close this console window.
If I then try to create a sample table with enter data in the model, or if I try to run in on any pbix with a model, I get this error:
Server port: localhost:57713, Database: f19f7559-9afc-45ad-8f3b-a7bc98ac400e
Microsoft.AnalysisServices.Tabular.TomInternalException: An internal error has occured.
in Microsoft.AnalysisServices.Tabular.ObjectFactory.CreatePartitionSourceFromType(PartitionSourceType type)
in Microsoft.AnalysisServices.Tabular.Partition.RecreatePartitionSourceIfMismatchWithPartitionType()
in Microsoft.AnalysisServices.Tabular.Partition.ReadAllBodyProperties(IPropertyReader reader)
in Microsoft.AnalysisServices.Tabular.DdlUtil.LoadDataTable(ObjectType objectType, DataTable table, Dictionary`2 objectMap, StringComparerInfo comparerInfo)
in Microsoft.AnalysisServices.Tabular.DdlUtil.LoadObjectsFromSchema(DataSet schema, ObjectType[] types, Dictionary`2& objectMap, StringComparerInfo comparerInfo)
in Microsoft.AnalysisServices.Tabular.DdlUtil.LoadModelFromSchema(DataSet schema, ObjectType[] objectTypes, Dictionary`2& objectMap, StringComparerInfo comparerInfo)
in Microsoft.AnalysisServices.Tabular.DdlUtil.DiscoverModel(Database db)
in Microsoft.AnalysisServices.Tabular.Database.LoadModel()
in Microsoft.AnalysisServices.Tabular.Database.get_Model()
in PbixSerialize.Program.Main(String[] args) in C:\Users\ABS01\source\repos\PbixSerialize\PbixSerialize\Program.cs:riga 21
Press Enter to close this console window.
In this case I created a table through enter data, named 'Table', with one column 'Column1' and a single value '1'.
Line 21 is
Console.WriteLine(db.Model);
Indeed I get the same error anytime I try to retrieve the Model.
Any idea on how to interpret the error and how to solve it?
Solved! Go to Solution.
I solved the problem.
It regards the library included.
With Nuget instead of installing "Microsoft.AnalysisServices.Tabular" which apparently is an old version one should install "Microsoft.AnalysisServices.retail.amd64".
This solved the problem.
I solved the problem.
It regards the library included.
With Nuget instead of installing "Microsoft.AnalysisServices.Tabular" which apparently is an old version one should install "Microsoft.AnalysisServices.retail.amd64".
This solved the problem.
Hi @ClaudioPat
Please check whether your custom connector has access to
C:\Users\ABS01\source\repos\PbixSerialize\PbixSerialize\Program.cs:riga 21
.
I think you can try to run it by administrator.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.