agracio / edge-js

Run .NET and Node.js code in-process on Windows, macOS, and Linux
MIT License
643 stars 95 forks source link

Microsoft.Data.SqlClient is not supported on this platform #191

Closed gaelazzo closed 8 months ago

gaelazzo commented 8 months ago

I modified the sample edge-js-quick-start to add Microsoft.Data.SqlClient (and I tried System.Data.SqlClient as well) trying to establish a SqlConnection, but I get the exception:

Microsoft.Data.SqlClient is not supported on this platform. at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString) in /_/artifacts/Project/obj/Release.AnyCPU/Microsoft.Data.SqlClient/netcore/net6.0/Microsoft.Data.SqlClient.notsupported.cs:line 422

My repository is edge-js-quick-start-sqlclient.

I've explored various avenues to resolve the issue, including modifying edge-js as well. However, I'm still unable to find a solution. Given the complexity of the problem and its impact on my work, I'm open to offering compensation for assistance in resolving this issue. I believe your expertise and insights could greatly contribute to finding a solution.

If you're available and willing to help, I'd greatly appreciate your assistance. Please let me know if you're interested, and we can discuss the details, including the compensation amount, further.

Thank you for considering my request.

Best regards, Gaetano Lazzo

agracio commented 8 months ago

Does that happen on windows?

gaelazzo commented 8 months ago

Yes It does.

agracio commented 8 months ago

In QuickStart.Core.csproj add the following references:

    <PackageReference Include="System.Collections" Version="4.3.0" />
    <PackageReference Include="System.IO" Version="4.3.0" />
    <PackageReference Include="System.IO.FileSystem" Version="4.3.0" />

Build then run dotnet publish src/QuickStart.Core/QuickStart.Core.csproj -c Release -r win-x64

in main.js replace

const baseNetAppPath = path.join(__dirname, '/src/'+ namespace +'/bin/Debug/net'+ net + version);

with

const baseNetAppPath = path.join(__dirname, '/src/'+ namespace +'/bin/Release/net'+ net + version + '/win-x64');
gaelazzo commented 8 months ago

Ok now I have another error: Error: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - Catena di certificati emessa da una Autorità di certificazione non disponibile nell'elenco locale.) So at least it solved that one. Now I have to solve this new one. But I want my project to be runnable also under Linux, so will I have to make different builds one for each target platform?

Note I'm open to compensating you for your time and expertise, as I'm eager to overcome these obstacles and make progress with the project.
Additionally, if you're willing to assist, could you please let me know the best way to contact you?

gaelazzo commented 8 months ago

I added ;TrustServerCertificate=true to the connection string and some little fixes on the sql command and I solved the error I was encountering. Many thanks

agracio commented 8 months ago

For different platform builds you need to specify correct dotnet publish -r <RID> although I am not sure you can publish for Linux using Windows you might need to build and publish separately on each platform.

gaelazzo commented 7 months ago

Many thanks !

agracio commented 5 months ago

Quick update: this issue does not appear to be present when using the latest release of Edge.js and System.Data.SqlClient instead of Microsoft.Data.SqlClient in your repo. However when using Microsoft.Data.SqlClient it does not work at all with C# code behaving erratically without showing any issues in Edge.js. I tried to investigate but nothing is making sense especially since Edge.js code executes as expected.

If you are upgrading to latest version of Edge.js note the change in EdgeJs.dll location as it it now .net version agnostic to simplify any future changes. node_modules/edge-js/lib/bootstrap/bin/Release/EdgeJs.dll