<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unhandled exception occurred while reading dataset (.NET Core) in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670787#M883</link>
    <description>&lt;P&gt;No idea. Do you have IOM configured and working in your environment? Easiest to work with, by far, is local provider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless you need to cross boundaries, don't.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jul 2020 23:02:59 GMT</pubDate>
    <dc:creator>AlanC</dc:creator>
    <dc:date>2020-07-20T23:02:59Z</dc:date>
    <item>
      <title>Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670443#M874</link>
      <description>&lt;P&gt;While reading the SAS dataset in .net core, I am getting the below exception. I have used&amp;nbsp; both the providers "sas.LocalProvider" and "sas.iomprovider.1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sas Program:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options formchar="|----|+|---+=|-/\&amp;lt;&amp;gt;*";&lt;/P&gt;
&lt;P&gt;proc means data=sashelp.cars;&lt;BR /&gt;class origin;&lt;BR /&gt;var msrp invoice;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;.net core program using "sas.iomprovider.1":&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using (OleDbConnection sas = new OleDbConnection($"provider=sas.iomprovider.1; SAS Workspace ID={sasLibrary}"))&lt;BR /&gt;{&lt;BR /&gt;string query = $"SELECT * FROM {sasLoadDataRequest.Data}";&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;System.Data.DataSet sasDs = new System.Data.DataSet();&lt;/P&gt;
&lt;P&gt;OleDbCommand command = new OleDbCommand(query, sas);&lt;BR /&gt;OleDbDataAdapter adapter = new OleDbDataAdapter(command);&lt;BR /&gt;adapter.Fill(sasDs);&lt;/P&gt;
&lt;P&gt;sas.Close();&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While reading the dataset "&lt;STRONG&gt;sashelp.cars&lt;/STRONG&gt;" getting the below error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Exception thrown at 0x00007FFCEAEBA799 in w3wp.exe: Microsoft C++ exception: _com_error at memory location 0x0000002BB63AD620.&lt;BR /&gt;The thread 0x443c has exited with code 0 (0x0).&lt;BR /&gt;The thread 0x5428 has exited with code 0 (0x0).&lt;BR /&gt;Exception thrown at 0x00000000100265C7 (sasaorio0902.dll) in w3wp.exe: 0xC0000005: Access violation reading location 0x000000004CC29C40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SAS program:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname test "F:\SAS App\";&lt;BR /&gt;options ls=72;&lt;BR /&gt;options formchar="|----|+|---+=|-/\&amp;lt;&amp;gt;*";&lt;/P&gt;
&lt;P&gt;proc means data=sashelp.cars;&lt;BR /&gt;class origin;&lt;BR /&gt;var msrp invoice;&lt;BR /&gt;output out=test.ds;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally using the same above sas program and using the below .net core program still getting the exception&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;.net core program using "sas.LocalProvider":&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using (OleDbConnection sas = new OleDbConnection($"Provider=sas.LocalProvider; Data Source=F:\\SAS App\\"))&lt;BR /&gt;{&lt;BR /&gt;string query = "ds";&lt;/P&gt;
&lt;P&gt;System.Data.DataSet sasDs = new System.Data.DataSet();&lt;/P&gt;
&lt;P&gt;OleDbCommand sasCommand = sas.CreateCommand();&lt;/P&gt;
&lt;P&gt;sasCommand.CommandText = query;&lt;BR /&gt;sasCommand.CommandType = CommandType.TableDirect;&lt;/P&gt;
&lt;P&gt;OleDbDataAdapter da = new OleDbDataAdapter(sasCommand);&lt;BR /&gt;da.Fill(sasDs);&lt;/P&gt;
&lt;P&gt;sas.Close();&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unhandled exception at 0x0000000010010B8C (sasafloc0902.dll) in w3wp.exe: 0xC0000005: Access violation reading location 0x000000005C5981D0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The above errors are crashing the w3wp.exe process.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly please help me resolve this error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670443#M874</guid>
      <dc:creator>mkraman</dc:creator>
      <dc:date>2020-07-19T15:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670474#M875</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 16:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670474#M875</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-07-19T16:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670476#M876</link>
      <description>&lt;P&gt;The same piece of code is working fine with the &lt;STRONG&gt;.net framework windows application&lt;/STRONG&gt; (SASHarness which is available in git) but not with the &lt;STRONG&gt;.net core 3.1&lt;/STRONG&gt; &lt;STRONG&gt;windows application&lt;/STRONG&gt;. I could see the same error appears here also and I guess is not with the IIS security rights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Moreover I could able to run the SAS program get the output but not able to read the dataset using the oledb.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had already given the full rights to the "IIS_IUSRS".&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 16:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670476#M876</guid>
      <dc:creator>mkraman</dc:creator>
      <dc:date>2020-07-19T16:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670479#M877</link>
      <description>&lt;P&gt;Also, please let me know how to provide access to the IIS.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 17:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670479#M877</guid>
      <dc:creator>mkraman</dc:creator>
      <dc:date>2020-07-19T17:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670521#M878</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Starting Test of SAS read...
Column: Region
Column: Product
Column: Subsidiary
Column: Stores
Column: Sales
Column: Inventory
Column: Returns
Completed...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        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();
        }&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        /// &amp;lt;summary&amp;gt;
        /// Gets a SAS dataset from the specified location
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="sasLibrary"&amp;gt;The physical location of the SAS library to read in the data &amp;lt;/param&amp;gt;
        /// &amp;lt;param name="dataset"&amp;gt;The name of the SAS dataset to read&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;.NET datatable&amp;lt;/returns&amp;gt;
        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;
        }&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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. &lt;STRONG&gt;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.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some notes on IIS I did so will put a few bits here to see if it loosens up some ideas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Under Application Pools in IIS, click on the service name you are using, choose Advanced Settings, change Identity to LocalSystem.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Add the following 2 accounts to the directory where the dataset is located:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;IIS APPPOOL\TheServiceName(or whatever you named it)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;NETWORK SERVICE&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 21:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670521#M878</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-07-19T21:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670523#M879</link>
      <description>&lt;P&gt;IIS_IUSRS is the old way of using IIS. it depends on your version of IIS. A later version of IIS uses Application Pools.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 21:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670523#M879</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-07-19T21:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670572#M880</link>
      <description>&lt;P&gt;Hi Alanc,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!! for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have used the below sample SAS cars program&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname test "F:\SASApp\";&lt;BR /&gt;options ls=72;&lt;BR /&gt;options formchar="|----|+|---+=|-/\&amp;lt;&amp;gt;*";&lt;/P&gt;&lt;P&gt;proc means data=sashelp.cars;&lt;BR /&gt;class origin;&lt;BR /&gt;var msrp invoice;&lt;BR /&gt;output out=test.ds;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could execute the application get output. But when I try using the code suggested and try to read the dataset,&amp;nbsp; 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\".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IIS APPPOOL\TheServiceName(or whatever you named it)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;NETWORK SERVICE&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is there any other permission needs to give?&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 06:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670572#M880</guid>
      <dc:creator>mkraman</dc:creator>
      <dc:date>2020-07-20T06:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670673#M881</link>
      <description>&lt;P&gt;Keep IIUSRS in there. Try with Everyone to see if lifting the restriction helps (make sure to revert after finding the culprit).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 14:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670673#M881</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-07-20T14:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670768#M882</link>
      <description>&lt;P&gt;Hi Alanc,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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}"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sas Program&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options ls=72;&lt;BR /&gt;options formchar="|----|+|---+=|-/\&amp;lt;&amp;gt;*";&lt;/P&gt;&lt;P&gt;proc means data=sashelp.cars;&lt;BR /&gt;class origin;&lt;BR /&gt;var msrp invoice;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this time I am getting the different below exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'sas.iomprovider.1' failed with no error message available, result code: -2147417851(0x80010105).&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 19:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670768#M882</guid>
      <dc:creator>mkraman</dc:creator>
      <dc:date>2020-07-20T19:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670787#M883</link>
      <description>&lt;P&gt;No idea. Do you have IOM configured and working in your environment? Easiest to work with, by far, is local provider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless you need to cross boundaries, don't.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 23:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/670787#M883</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2020-07-20T23:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Unhandled exception occurred while reading dataset (.NET Core)</title>
      <link>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/709062#M1076</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jan 2021 13:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Unhandled-exception-occurred-while-reading-dataset-NET-Core/m-p/709062#M1076</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2021-01-02T13:08:50Z</dc:date>
    </item>
  </channel>
</rss>

