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

[Question] System.Data.SqlClient could not be found on my plugin #288

Open
johmarjac opened this issue Dec 17, 2023 · 3 comments
Open

[Question] System.Data.SqlClient could not be found on my plugin #288

johmarjac opened this issue Dec 17, 2023 · 3 comments
Labels
question Further information is requested

Comments

@johmarjac
Copy link

Hello,

I have tried this library now with a simple plugin. All my projects reference net8.0-windows as I need WPF user controls in my plugins.
But in not a single project i am in any way referencing System.Data.SqlClient, i am not using it... So why does it throw exception when trying to create a loder?

thanks

@johmarjac johmarjac added the question Further information is requested label Dec 17, 2023
@johmarjac
Copy link
Author

johmarjac commented Dec 19, 2023

Okay, I have tracked the issue down to where the problem comes from. In my Plugin contract I have a reference to System.Windows.Controls.TabItem like this:

public interface IPlugin
{
    string Name { get; }

    TabItem? TabItem { get; }
}

Plugin Implementation as simple as this:

public class Class1 : IPlugin
{
    public string Name => "TEST PLUGIN";

    public TabItem? TabItem { get; } = new TabItem()
    {
        Header = "NModbus",
        Content = new ContentControl()
    };
}

As soon as I have that TabItem reference in there, I get this error when trying to create a loader from that plugin:

image

Why is that?

Edit: When I add all those NuGet Packages:

<PackageReference Include="System.Data.Odbc" Version="8.0.0" />
<PackageReference Include="System.Data.OleDb" Version="8.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.Runtime.Serialization.Schema" Version="8.0.0" />
<PackageReference Include="System.ServiceModel.Syndication" Version="8.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />

then it works. but why is all those packages necessary? any idea?

@paschal77
Copy link

I am seeing the same issue. It's almost as if the Context Loader can't find the locally installed .NET framework. Did you happen to find any answer to this? @johmarjac

@jgmdavies
Copy link

Frustrating, isn't it? ;---)

I found a quick workaround was to use this configuration option:

var loader = PluginLoader.CreateFromAssemblyFile(file, config => config.PreferSharedTypes = true);
This has various implications which are explained - I could find the link tomorrow if you don't have it - but gets it working nicely!

HTH
Jim

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

No branches or pull requests

3 participants