Skip to content
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

Assembly loading - PlatformNotSupportedException #761

Closed
Benjiinator opened this issue Oct 16, 2020 · 17 comments
Closed

Assembly loading - PlatformNotSupportedException #761

Benjiinator opened this issue Oct 16, 2020 · 17 comments

Comments

@Benjiinator
Copy link

I am in the middle of migrating a large project from .net framework -> .net core 3.1 and during the process i am encountering "Microsoft.Data.SqlClient is not supported on this platform".

My project solution consists of the following:

  • .Net core 3.1 program that can load and run plugin modules through assembly.
  • .Net standard 2.0 plugin modules with dependecies (1 of which has a dependency on Microsoft.Data.SqlClient)

I have read the FAQ point 11 which refers to what sounds like my problem - however, i am still oblivious as to how i am to solve the problem.

@cheenamalhotra
Copy link
Member

Hi @Benjiinator

Is it possible to wrap a repro application and upload it here to take a closer look?
It does look like what is mentioned in point 11 may apply to your case.

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

I will attempt creating one and get back to you.

@Benjiinator
Copy link
Author

Hi @cheenamalhotra
I have created a repro application and the issue still persists.
I have set it up to build the needed librarys to the path "C:/AssemblyLoading".

When publishing the exe itself i used the following settings:

  • Deployment mode: self contained
  • Target Runtime: win-x64
  • Produce single file: true

@cheenamalhotra
Copy link
Member

Hi @Benjiinator

If you specify "RuntimeIdentifier" in your PluginShared.csproj, that seems to resolve the issue:

image

I now see correct DLL being referenced in *.deps.json files:

image

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

After setting the "RuntimeIdentifier", cleaning, rebuilding and publishing the application the issue is still present.

@cheenamalhotra
Copy link
Member

Could you also specify the same in DemoPlugin.csproj and try again?

It seems that project also needs a RuntimeIdentifier to yield this:

image

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

This resolved my issue.

Many thanks for the help - it is much appreciated.

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

After implementing your solution i now am getting the following error: "Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)" when i attempt running it on my production environment.

@Benjiinator Benjiinator reopened this Oct 23, 2020
@cheenamalhotra
Copy link
Member

Hi @Benjiinator

We depend on native runtime library "Microsoft.Data.SqlClient.SNI.dll" which could usually be found on runtimes directly from where all runtime DLLs are loaded. If you haven't provided Execute permissions there (common possibility in Production env), it might be the reason your application will have issues. Please take a look at #385 (comment) and related discussion for more details.

@Benjiinator
Copy link
Author

Benjiinator commented Oct 26, 2020

Hi @cheenamalhotra

I'm not quite sure how to proceed with this issue, my application is not running on iis - it is a windows service running on an administrator account.
The directory of the application does have Read & Execute permissions for the administrator account - I must be missing something.

@cheenamalhotra
Copy link
Member

Runtime native DLLs are fetched from NuGet Cache location in .NET Core, so you will need to verify permissions to that folder too.

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

A NuGet cache is not present on my production environment - i looked for it under "%localappdata%" + "/NuGet/Cache" but the NuGet folder is not present.

@cheenamalhotra
Copy link
Member

Hi @Benjiinator

You may find your NuGet cache location by running this tool and verify if you have required permissions:
dotnet nuget locals (details)

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

After running the tool i got found out the following:

  • http-cache: C:\Users\Administrator\AppData\Local\NuGet\v3-cache - path does not exist
  • global-packages: C:\Users\Administrator.nuget\packages\ - path does not exist
  • temp: C:\Users\Administrator\AppData\Local\Temp\2\NuGetScratch - administrator account has all permissions
  • plugins-cache: C:\Users\Administrator\AppData\Local\NuGet\plugins-cache - path does not exist

@Benjiinator
Copy link
Author

Benjiinator commented Oct 29, 2020

Hi @cheenamalhotra

Any ideas what else could be wrong when the cache locations either does not exist on the production environment or exists and has the proper permissions?

@Benjiinator
Copy link
Author

Hi @cheenamalhotra

Any updates on this issue? - it is the last thing keeping us from fully migrating to .Net Core.

@Benjiinator
Copy link
Author

@cheenamalhotra After upgrading from .Net Core 3.1 to .Net 5.0 the issue disappeared.
Thanks for your help though - it is greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants