Rhino.Inside (Rhino 7) Error in WPF

Hi! I’m trying to host Rhino 7 via Rhino.Inside inside a WPF app and I’m running into license

Environment

  • Windows: [Windows 10]

  • Rhino: 7.38, 64-bit (standalone Rhino launches fine with my commercial license)

  • Host app: WPF, net7.0-windows (x64), Rhino.Inside NuGet 7.0.0

  • Build: x64, Prefer32Bit=false, not single-file

Problem

  • When I start the app, I get:
    “Rhino license manager initialization failed with error 0. Rhino will not run.”

  • If I change WindowStyle to NoWindow, the error becomes a COMException E_FAIL at new RhinoCore(...).

  • This happens whether Rhino 7 is already open or closed.

What I’ve tried

  • Only Rhino.Inside package; removed any direct references to RhinoCommon / RhinoWindows (and removed any copies from bin).

  • Followed Ehsan’s guidance for WPF entry point (use a custom Program.Main, call RhinoInside.Resolver.Initialize() before touching any Rhino types; don’t set PATH or change CWD).

  • First run with WindowStyle.Normal (not Hidden/NoWindow), to allow license UI if needed.

  • Cleared env vars that might interfere: RHINO_PLUGIN_PATH, RHINO_COMMON_DIR, RHINO_LICENSE_METHOD.

  • Cleaned bin/obj, repaired Rhino 7 installation.

  • Confirmed Rhino 7 launches normally outside my app (license OK).

Questions

  • Are there known causes for “license manager initialization failed with error 0” when hosting Rhino 7 via Rhino.Inside?

  • Is there any additional requirement for the License Manager plug-in to load under Rhino.Inside (e.g., specific env vars, plugin path assumptions)?

     public partial class App : Application
        {
            private RhinoCore? _core;
    
            protected override void OnStartup(StartupEventArgs e)
            {
                base.OnStartup(e);
    
                var sys = @"C:\Program Files\Rhino 7\System";
                if (!File.Exists(Path.Combine(sys, "RhinoLibrary.dll")))
                    throw new InvalidOperationException("Rhino 7 not found.");
    
                var path = Environment.GetEnvironmentVariable("PATH") ?? "";
                if (!path.Split(Path.PathSeparator).Any(p => p.TrimEnd('\\').Equals(sys.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase)))
                    Environment.SetEnvironmentVariable("PATH", sys + Path.PathSeparator + path);
    
                Environment.SetEnvironmentVariable("RHINO_SYSTEM_DIR", sys);
                Directory.SetCurrentDirectory(sys);
    
                RhinoInside.Resolver.Initialize();
    
                var args = new[] { "/NOSPLASH", "/NOTEMPLATE" };
                _core = new Rhino.Runtime.InProcess.RhinoCore(args, Rhino.Runtime.InProcess.WindowStyle.Hidden);
                new Views.MainWindow().Show();
            }
    
        }
    

Hi @Lucas_NG,

Rhino 7 targets the .NET Framework 4.8.

– Dale

@Dale Thanks

I am developing a WPF application that integrates Rhino using Rhino.Inside.
I managed to create the app, load the RhinoCore, and host a ViewportControl inside a WindowsFormsHost. The control shows up, but it never renders (stays gray, Paint event never fires).
I have already tried initializing RhinoCore with -embedded, -appmode, /NOSPLASH, creating the App instance before RhinoCore (as suggested), and even delaying the WorkspaceView creation until RhinoCore is active. Still, the ViewportControl does not draw anything.

using System;
using System.Windows;
using Rhino;
using RhinoInside;

namespace RhinoWpfTest
{
    internal class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // 1. Enable Rhino resolver before anything touches RhinoCommon
            RhinoInside.Resolver.Initialize();

            // 2. Start WPF application
            var app = new App();
            app.InitializeComponent();

            // 3. Start RhinoCore in embedded mode
            _core = new Rhino.Runtime.InProcess.RhinoCore(
                new string[] { "/NOSPLASH", "-embedded" },
                Rhino.Runtime.InProcess.WindowStyle.Hidden);

            // 4. Run main window
            var mainWindow = new MainWindow();
            app.MainWindow = mainWindow;
            mainWindow.Show();
            app.Run();

            _core.Dispose();
        }

        private static Rhino.Runtime.InProcess.RhinoCore _core;
    }
}
<Application x:Class="RhinoWpfTest.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             ShutdownMode="OnMainWindowClose">
</Application>
<Window x:Class="RhinoWpfTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
        xmlns:rhino="clr-namespace:RhinoWindows.Forms.Controls;assembly=RhinoWindows"
        Title="Rhino Inside WPF Test"
        Width="800" Height="600">
    <Grid>
        <wfi:WindowsFormsHost x:Name="Host"/>
    </Grid>
</Window>
using System.Windows;
using RhinoWindows.Forms.Controls;

namespace RhinoWpfTest
{
    public partial class MainWindow : Window
    {
        private ViewportControl _vp;

        public MainWindow()
        {
            InitializeComponent();

            // Attach Rhino viewport
            _vp = new ViewportControl
            {
                Dock = System.Windows.Forms.DockStyle.Fill
            };
            Host.Child = _vp;
        }
    }
}

With this minimal example, the ViewportControl shows up but does not render anything (stays gray, no Paint event).

What is the correct and minimal way to initialize RhinoCore inside a WPF application so that the ViewportControl actually renders?
Is there an official boilerplate for this scenario (WPF + Rhino.Inside + ViewportControl)?

Hi @Lucas_NG,

I don’t know of anything “official”.

Here is an example of a standalone C# application that uses the ViewportControl object. This example uses Eto.

And here is a Rhino plug-in that uses the ViewportConrol with WPF.

Maybe all this helps?

– Dale

1 Like

Hi,

Thanks for sharing the samples. I was able to get what I needed based on those examples, they really helped. Appreciate your support!

Best,
Lucas

Hi,@Lucas N.G.

I downloaded the official Rhino.Inside sample files (https://github.com/mcneel/rhino-developer-samples/tree/8/rhino.inside), and they run correctly. However, when I try to create my own HelloWorld project or open Rhino in a WPF project, I always encounter errors like this:

System.DLLNotFoundException: Unable to load DLL ‘RhinoLibrary’. The specified module could not be found. (Exception from HRESULT: 0x800700E). This exception was originally thrown at this call stack: Rhino.Runtime.InProcess.RhinoCore()

I just created a controller application or a WPF project using Visual Studio, and the issue remains the same. Could you please send me a simple, runnable WPF project example? Thank you so much!