Rhino8 Plugin using Class Library with Version .Net 7.0

Hello there,

I am starting a new plugin for Rhino8.
So I have come across a problem when writing a class library for this plugin.

First I created the plugin, complied and it worked fine in Rhino8.
Then I created a class library using a net7.0 (.NetCore) ClassLibrary.
After this i did what is required here:

So, now here’s the problem:

|Error|NU1201|Project Fasteners is not compatible with net48 (.NETFramework,Version=v4.8). Project Fasteners supports: net7.0 (.NETCoreApp,Version=v7.0)|Screwery|C:\Users\tstoltmann\Desktop\stoltm\C#\Rhino\APPS\Screwery\Screwery.csproj|1||

I absolutely have no idea what’s wrong.
Did i chose the wrong type of class library?
My intention using net7.0 (.NetCore) ClassLibrary is to be most up to date. But maybe I got something wrong here.

Thanks,
T.

I suspect you are trying to reference one project from another? Are Both net7.0 class library projects? The error message suggests that the “Screwery” project is .net4.8

@david.birch.uk
yes, correct.
“Screwery” is the rhino-plugin, created from the template.
Do I need to updated anything in the VS-template here?

You can reference 4.8 from a 7 project
But you cannot reference a 7 project from a 4.8 project

I assume the Wizard you show has created a 4.8 project.

so you’d need to update the Plugin Project to use net7.0

There is an upgrade tool in Visual Studio - Right click the project and go through Upgrade.

hi @david.birch.uk
thanks for the input in the first place.
It all sounds logic and I will try.

I wonder why this one below does not work.
As far as I understand it, this should help, right?
Or is the template downloadable in VS still not up to date?

@david.birch.uk
Also the strange thing is that in the properties of the project I find that the target framework is supposed to be 7.0.

image

Maybe @curtisw can confirm but I think the official advice is to multi-target - and the samples are set up that way - that means to write code compatible with both frameworks - but if you do that you cannot reference .net7 only projects as you have found.

What i think you are asking for is to target .net 7 only - to do that run the upgrade tool on the project.

Looking at your screenshot, you are already multi targeting (Net Framework 4.8 and Net 7).

In this setup, you won’t be able to use DLLs compiled for .net 7

The official recommendation from McNeel is to ship your plugins for 4.8 (compatibility with R7, Rhino Inside, etc.) but test them in Net7 to make sure everything works as expected.

What should you do? Multi target both your plugin and external library, reference the 4.8 DLL in your plugin.

1 Like

Yes, we added multi-targeting to Rhino 8.3, which allows you to distribute a single multi-targeted plugin or yak package. This is not required, and only recommended if you want to take advantage of .NET 7 only features. There are also 3rd party libraries that require different versions of their assemblies for net4x vs. net7+, so it would be required in those scenarios to multi-target.

Do note that if you do not target net48, it will fail to load in Rhino 7 and also Rhino 8 when running in .NET Framework.

We really do need to update our developer documentation and guides to address these scenarios, and thanks for your patience as we work through it.

Hope this helps,
Curtis.

2 Likes

@david.birch.uk, @mrhe and @curtisw
Understood and thanks a lot.