-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MS Access support in .net core #654
Comments
I don't know, let's try. :-) |
That is now included in SQLProvider 1.1.79 But no-one has tried to create a project with it yet. :-) |
Hi, Thanks for the update, I tried it with version 1.1.79 and 1.1.81 (retrieved using nuget), and I am getting the following error:
This is the same error as with older versions, which seems to come from SqlRuntime.DataContext.fs when trying to pattern match to see if it isn't using .net standard. This is the code that I am running: ` open System
which works in .net framework but not with .net core or .net standard |
Sorry, forgot one thing, can you try 1.1.82 please? |
Hi, Thanks for the update, I am now getting the following error
This error only shows after I close and reopen the project after upgrading, if I just upgrade and don't close and reopen it will still show the old error. I have tried also downloading System.Data.OleDb version 4.7 from nuget to see if it solved the error, but the error remains. The .net framework project still works. |
As a temporary fix, can you try to copy the System.Data.OleDb.dll to nuget-cache (Edit: fixed the version in the path to 1.1.82) |
Hi, Thanks for the tip, hadn't thought about doing that, I have copied the "System.Data.OleDb.dll" to the specified folder (1.1.82 not the 1.1.79 originally mentioned), and I am now getting the following error:
Have tried downgrading from .netcore 3.1 to 2.2, 2.0 and setting the target platform to x86 and x64, but none of them seemed to have made a difference. Was able to get it going by using the oledb.ddl from the net461 folder instead of the .netstandard2.0 but as expected one then runs into problems with using a net framework package in a .net core application (in this case problems while writing to the DB). |
No it should be net461 version, because TypeProviders are compiled with .NET Framework and then in the runtime you should replace it with the .NET Core/Standard dll. This is how type providers work right now, which is messy, I hope they'll change it in the future. Edit: So in your project you'll still reference the .NET Standard version of dll, just the .nuget package cache is the .NET Framework version. As I expect that did help, I'll fix this to be automatic in the next releases. :-) |
Hi, In that case, after copying the file named System.Data.OleDb.dll from the "system.data.oledb.4.7.0.nupkg\lib\net461" into the specified 1.1.82 folder, the error that I am getting now is the following:
This error only shows up after running the app, it does not show before compiling, unlike previous errors, more precisely the error seems to be triggered when trying to get the data context by using GetDataContext(), which is strange because the datacontext works fine in the IDE, so for example I can do something like:
And the IDE will give me intelisense completion for records in the database and everything, proving that accessing the database is working, but as soon as I actually run this code (which works fine in .net Framework) it gives the previously mentioned error. |
We are very close here... Now, try the 1.1.83 package, don't touch the .nuget cache, Something like this, depending on your OS, paths and TargetFramework: ...
<ItemGroup>
<PackageReference Include="System.Data.OleDb" Version="4.7.0" />
<PackageReference Include="SQLProvider" Version="1.1.83" />
</ItemGroup>
<Target Name="AccessCopyLibrariesWin">
<Exec Command="xcopy ..\packages\System.Data.OleDb\runtimes\win\lib\netstandard2.0\System.Data.OleDb.dll bin\Debug\netcoreapp2.0\ /y" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<CallTarget Targets="AccessCopyLibrariesWin" />
</Target> I wonder what are the differences, and what should be used when in the package System.Data.OleDb:
|
Hi, Thanks for the update, tried it along with the instructions you gave, and I am getting some errors when doing SubmitUpdates() on the dataContext. When using a database I am using for another project I get this error:
When using a blank database I created with just 1 test table and 1 test field I get the following error:
Both these errors happen when calling SubmitUpdates(), just like before the code to do this in the databases works in a netframework project. I also tried using the 3 different System.Data.OleDb.dll you posted in the xcopy command and none made any difference to the errors displayed. |
Ok, so it's basically working....? Access drivers has its tricks, for the SubmitUpdates try to disable transactions:
|
One thing I remember with MS Access was that it cannot handle multiple simultaneous connections to the same database file. It used to give "Unknown Error" if that happened, e.g. by something leaving the connection open. The "Attempted to read or write protected memory." is not SQLProvider error, but somewhere below that. Is there a specific case when this happens, or always? Does restarting the Visual Studio help? |
Unfortunately it isn't a multiple connection error, or any occasional thing, I had already tried to close and reopen Visual Studio, along with creating a new project in a different machine and copying the Db file to it, and I get the same error (for both databases) in the 2 machines I tested it in, and it also happens with x86 and x64. Both databases seem to run into problems only with the SubmitUpdates() even if they are different problems, because I can access the DB in the IDE, and I can execute a query in the databases and get results back without running into any issue. Any other suggestions I can try? |
Was able to finally do a bit more digging and it seems this might be an issue with the version 4.7 of System.Data.OleDb, since the error seems to be the same as #dotnet/runtime#981 now issue #dotnet/runtime#32509 |
I am wondering if there is currently any obstacle to having MS Access databases to work in .net core, from what I was able to find out part of the issue initially was that there was no System.Data.OleDb for .net core, but Microsoft has released this a few months ago https://www.nuget.org/packages/System.Data.OleDb so I am wondering if that was all that was missing or if there are other things missing still from .net core to make it work?
Thank you.
The text was updated successfully, but these errors were encountered: