Reading data from Rhinofile in WPF App fails

Hi there,

I tried to access a 3dm-file from a WPF app to be able to read inforrmation in the file without opening Rhino.
I found a similar case here:


So I came up with this code:

public MainWindow()
    {
        InitializeComponent();

        var file_path = @"C:\Testifle.3dm";
        var file_data = Rhino.FileIO.File3dm.Read(file_path);
        
    }
}

When I install RhinoCommon via NuGet everything seems fine, but when I compile the code the following happens.

System.Windows.Markup.XamlParseException
HResult=0x80131501
Message=‘The invocation of the constructor on type ‘WpfApp1.MainWindow’ that matches the specified binding constraints threw an exception.’ Line number ‘6’ and line position ‘9’.
Source=PresentationFramework
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
Inner Exception 1:
FileNotFoundException: Could not load file or assembly ‘RhinoCommon, Version=6.27.20176.5000, Culture=neutral, PublicKeyToken=552281e97c755530’ or one of its dependencies. The system cannot find the file specified.

Is this an installation issue?
Basically I am okay in C#, but I cannot handle this one…

Thanks,
T.

Hi @tobias.stoltmann1,

The RhinoCommon.dll, that is included with Rhino, can only be used inside of Rhino - either from a Rhino plug-in, from a Grasshopper component, or from a Rhino.Python script.

If you want to read 3dm files from outside of Rhino, then you install the Rhino3dmIO NuGet package.

Does this help?

– Dale

1 Like

Hi @dale,
working perfectly fine. :slight_smile:
Thanks.