问题
I am attempting to automate partition refreshes in Azure Analysis Services via C#. I have installed and referenced the latest 'Microsoft.AnalysisServices. ..' assemblies found here:
https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers.
I then have the following code:
using System; using Microsoft.AnalysisServices.Tabular;
public void Run()
{
Server asSrv = new Server();
try
{
asSrv.Connect(ASConnectionString);
Database db = asSrv.Databases.FindByName("HospoIQTabular");
Model m = db.Model;
// only refresh 2017 partitions
m.Tables["Sales"].Partitions["Sales - Post 2017"].RequestRefresh(RefreshType.Full);
m.Tables["Payments"].Partitions["Payments - Post 2017"].RequestRefresh(RefreshType.Full);
db.Model.SaveChanges(); // commit which will execute the refresh
}
catch (Exception e)
{
OnEventLog(e.Message);
}
finally
{
asSrv.Disconnect();
asSrv = null;
}
}
Connect to the server and database itself works fine. However, attempting to reference 'db.Model' throws the following exception:
The value '2' is unexpected for type 'DataSourceType'.
I've looked but can't find any help anywhere on this. Any thoughts??
回答1:
For me, the path that worked was C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies
but only after reading Andrae comment which sent me on the right direction
回答2:
The problem is similar with the NuGet package Microsoft.AnalysisServices.Tabular (v13)
Fortunately you can use the NuGet packages listed here: https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers.
In Visual Studio NuGet lists this package as Microsoft.AnalysisServices.retail.amd64
来源:https://stackoverflow.com/questions/44296949/exception-when-referencing-ssas-tabular-model-in-c-sharp