Search code examples
c#impersonationssas-tabular

Connecting To Analysis Services Tabular Model


I have a .NET 6 application that's trying to connect to an Analysis Services Tabular model stored on an Analysis server. I'm using this code to connect. (I replace the dashes with the correct Analysis server name before running).

        using Microsoft.AnalysisServices.Tabular;

        private void button1_Click(object sender, EventArgs e)
        {
            var serverName = "------------";
            using var server = new Server();                        
            server.Connect($"Provider=MSOLAP; Data Source={serverName};");
        }

But the connection attempt fails with the following error:

System.TypeLoadException: 'Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'

How do I resolve this error? Do I have to add something to my connection string to set the impersonation mode?


Solution

  • .NET 5 and later are based on .NET Core, and are cross-platform.

    To connect from .NET 5 or later use the ADOMD.NET for .NET Core or AMO for .NET Core.