While reading the SAS dataset in .net core, I am getting the below exception. I have used both the providers "sas.LocalProvider" and "sas.iomprovider.1"
Sas Program:
options formchar="|----|+|---+=|-/\<>*";
proc means data=sashelp.cars;
class origin;
var msrp invoice;
run;
.net core program using "sas.iomprovider.1":
using (OleDbConnection sas = new OleDbConnection($"provider=sas.iomprovider.1; SAS Workspace ID={sasLibrary}"))
{
string query = $"SELECT * FROM {sasLoadDataRequest.Data}";
System.Data.DataSet sasDs = new System.Data.DataSet();
OleDbCommand command = new OleDbCommand(query, sas);
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(sasDs);
sas.Close();
}
While reading the dataset "sashelp.cars" getting the below error
Exception thrown at 0x00007FFCEAEBA799 in w3wp.exe: Microsoft C++ exception: _com_error at memory location 0x0000002BB63AD620.
The thread 0x443c has exited with code 0 (0x0).
The thread 0x5428 has exited with code 0 (0x0).
Exception thrown at 0x00000000100265C7 (sasaorio0902.dll) in w3wp.exe: 0xC0000005: Access violation reading location 0x000000004CC29C40.
SAS program:
libname test "F:\SAS App\";
options ls=72;
options formchar="|----|+|---+=|-/\<>*";
proc means data=sashelp.cars;
class origin;
var msrp invoice;
output out=test.ds;
run;
Finally using the same above sas program and using the below .net core program still getting the exception
.net core program using "sas.LocalProvider":
using (OleDbConnection sas = new OleDbConnection($"Provider=sas.LocalProvider; Data Source=F:\\SAS App\\"))
{
string query = "ds";
System.Data.DataSet sasDs = new System.Data.DataSet();
OleDbCommand sasCommand = sas.CreateCommand();
sasCommand.CommandText = query;
sasCommand.CommandType = CommandType.TableDirect;
OleDbDataAdapter da = new OleDbDataAdapter(sasCommand);
da.Fill(sasDs);
sas.Close();
}
Unhandled exception at 0x0000000010010B8C (sasafloc0902.dll) in w3wp.exe: 0xC0000005: Access violation reading location 0x000000005C5981D0.
The above errors are crashing the w3wp.exe process.
Kindly please help me resolve this error.
It looks like your IIS process does not have security to access the SAS dataset. That is a 1quick guess based upon looking up the process and the error I see below. Check that first. IIS is finicky on security rights.
The same piece of code is working fine with the .net framework windows application (SASHarness which is available in git) but not with the .net core 3.1 windows application. I could see the same error appears here also and I guess is not with the IIS security rights.
Moreover I could able to run the SAS program get the output but not able to read the dataset using the oledb.
I had already given the full rights to the "IIS_IUSRS".
IIS_IUSRS is the old way of using IIS. it depends on your version of IIS. A later version of IIS uses Application Pools.
Also, please let me know how to provide access to the IIS.
Ok, I just took one of my old code libraries and updated it to Core 3.1 as a console app. Used the SAS OleDb provider. Ran it against the shoes dataset and produced the following:
Starting Test of SAS read...
Column: Region
Column: Product
Column: Subsidiary
Column: Stores
Column: Sales
Column: Inventory
Column: Returns
Completed...
I will try and clean the library up and make it a nuget package. For now, here is the code that illustrates what I am doing.
static void Main(string[] args)
{
WriteLine("Starting Test of SAS read...", Color.White);
var utils = new Utilities();
var ds = utils.GetDataSet(@"z:\scratch","shoes");
foreach (var c in ds.Columns)
{
WriteLine($"Column: {c}", Color.LightBlue);
}
WriteLine("Completed...");
ReadKey();
}
/// <summary>
/// Gets a SAS dataset from the specified location
/// </summary>
/// <param name="sasLibrary">The physical location of the SAS library to read in the data </param>
/// <param name="dataset">The name of the SAS dataset to read</param>
/// <returns>.NET datatable</returns>
public DataTable GetDataSet(string sasLibrary, string dataset)
{
OleDbConnection sas = null;
DataTable dt = new DataTable(dataset);
try
{
sas = new OleDbConnection(@"Provider=SAS.LocalProvider.1; Data Source=" + sasLibrary);
sas.Open();
OleDbCommand sasCommand = sas.CreateCommand();
sasCommand.CommandType = CommandType.TableDirect;
sasCommand.CommandText = dataset;
OleDbDataReader sasRead = sasCommand.ExecuteReader();
dt.Load(sasRead);
sas.Close();
}
catch (Exception ex)
{
sas.Close();
string errMessage = "Unable to get the SAS dataset. Library: " + sasLibrary + ", DataSet: " + dataset + ", " +
ex.TargetSite.Name;
HandleError(MethodBase.GetCurrentMethod().Name, ex);
}
finally
{
sas.Close();
}
return dt;
}
If the above code does not work, for you, in a console app, then you have other issues. I suspect IIS permissions. Look for my old blog "Sas: Out In Left Field" and I should have something out there addressing IIS usage. I have done that numerous times in the past. However, I don't use IIS anymore and rely on Kestrel for serving up pages. Consider doing that yourself and start moving away from IIS.
I have some notes on IIS I did so will put a few bits here to see if it loosens up some ideas.
Under Application Pools in IIS, click on the service name you are using, choose Advanced Settings, change Identity to LocalSystem.
Add the following 2 accounts to the directory where the dataset is located:
IIS APPPOOL\TheServiceName(or whatever you named it)
NETWORK SERVICE
Hi Alanc,
Thank you!!! for your quick response.
I have used the below sample SAS cars program
libname test "F:\SASApp\";
options ls=72;
options formchar="|----|+|---+=|-/\<>*";
proc means data=sashelp.cars;
class origin;
var msrp invoice;
output out=test.ds;
Run;
I could execute the application get output. But when I try using the code suggested and try to read the dataset, I am still getting the same exception even after adding the accounts to the directory where the dataset is available in this case it is "F:\SasApp\".
IIS APPPOOL\TheServiceName(or whatever you named it)
NETWORK SERVICE
Is there any other permission needs to give?
Keep IIUSRS in there. Try with Everyone to see if lifting the restriction helps (make sure to revert after finding the culprit).
It is hard for me to diagnose this remotely so use my ideas as a starting point. It depends on the version of IIS and other factors.
Boil your stuff down to just what is essential. A dataset, in a directory. No SAS code involved, just a dataset. Try to read it from an ASP.NET test page. Ignore integrating it into your project just make a simple dummy test and start there until you get the security figured out.
Hi Alanc,
I have hosted the application in kesteral as mentioned in the previous trail. This time I am using the connectionstring "provider=sas.iomprovider.1; SAS Workspace ID={uniqueidentifier}"
Sas Program
options ls=72;
options formchar="|----|+|---+=|-/\<>*";
proc means data=sashelp.cars;
class origin;
var msrp invoice;
run;
But this time I am getting the different below exception.
'sas.iomprovider.1' failed with no error message available, result code: -2147417851(0x80010105).
No idea. Do you have IOM configured and working in your environment? Easiest to work with, by far, is local provider.
Unless you need to cross boundaries, don't.
I just encountered this issue as well. Easiest thing to do is to reinstall the SAS Int Tech client. My guess is that the COM component gets unregistered. Rather than re-registering, just reinstall.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.