Issue using Icon in Panel.RegisterPanel()

Hi! I’m trying to create a Eto Panel with Panels.RegisterPanel() in RhinoCommon. However I’m facing a problem with the Icon part.

If I add a Icon to the Resources as byte, I cannot use it in Panel.RegisterPanel(), due to
cannot convert form 'byte to ‘System.Drawing.Icon’ , as shown below:

But If I add the icon as System.Drawing.Icon, then I cannot find it in the resources, also in resource designer, it shown as ‘Fail to load resource value’, as shown below:

Currently my solution is just covert byte to a icon using MemeoryStream, is there a better solution? Because in the Rhino Eto Sample(rhino-developer-samples/rhinocommon/cs/SampleCsEto at 8 · mcneel/rhino-developer-samples · GitHub) everything works.

Thank you!

Hey @Hao_Wu1,

This is unfortunately a problem with the “new” resource designer in Visual Studio 2022 - in that it creates broken .resx files with System.Drawing.Icon/Bitmap. Edit: Some info about others running into the same issue is here. It appears it might be fixed in a future VS update.

The problem is that it should set the type to System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a instead of the above with mscorlib.

You can get around this by either editing the .resx manually, or my usual go-to is to use the old resource designer by right clicking the .resx, clicking Open With..., then selecting the Managed Resources Editor (legacy). You can also set it as default so you won’t run into this again.

Hope this helps!

3 Likes

Hey Curtis,

Thank you so much!