Loading assembly from RH plugin instead of GH plugin threw an exception

I have developed a plugin for Grasshopper, and there is another plugin for Rhino as well. The issue arises when the Grasshopper plugin tries to load an assembly from the Rhino plugin, resulting in an exception. How can I manage this situation to ensure that the Grasshopper connector loads the assembly exclusively, without relying on the Rhino plugin? The exception message states: “Add value to collection of type ‘Microsoft.Xaml.Behaviors.BehaviorCollection’ threw an exception.”

if I delete above dll from rhino plugin bin folder then grasshopper connector works fine but its not workable solution

So any one can help me for same
Thanks in advance

I need more details to fully understand your issue…

The Microsoft.Xaml.Behavior is the new way of dealing with WPF Behaviors, so I assume you have some WPF UI that is causing your issue…

Can you explain more about your situation?

thanks for rply @jstevenson ,
currently I am using usercontrol class(Wpf) for adding combo box inside UI.
Is this creating any issue?

Window x:Class=“SampleTest.UI.Mapping”
Title=“Sample UI Settings” Height=“130” Width=“450”>
< Grid>
///Code functionality //

That isn’t a User control that is a Window. And your comment syntax isn’t valid Xanl.

Xanl comments must start with <!-- and end with –>

That will throw an exception.

Ah, I see. My apologies for the confusion. It seems I provided incorrect information earlier. It is an window and Additionally, I am not using the comment syntax only so right now i share total code block
so is this creating issue for the exception i mention earlier

<Window x:Class="SampleTest.UI.Mapping"
        Title="Data Exchange Settings" Height="130" Width="450">
        <StackPanel Width="400" Height="50" VerticalAlignment="Top">
            <Label Name="MapCategory" Width="300" HorizontalAlignment="Left" FontWeight="Bold">
                <TextBlock TextWrapping="WrapWithOverflow">
   Layer to Category Mapping
            <CheckBox Height="28" x:Name="MapLayerConfirmation" Margin="10,0" Checked="MapLayerConfirmationChecked" Unchecked="MapLayerConfirmationChecked">Place elements on different layers based on their categories.
        <StackPanel Width="400" Height="50" VerticalAlignment="Bottom">
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="auto" />
                <Button Grid.Column="1" Margin="57,10,80,0" x:Name="Load" Click="LoadButtonClicked" Content="Load" RenderTransformOrigin="0.946,0.483" />
                <Button Grid.Column="1" HorizontalAlignment="Center" Margin="134,10,10,0" x:Name="Cancel" Click="CancelButtonClicked" Content="Cancel" Width="56" RenderTransformOrigin="-0.048,0.417"/>

There isn’t anything in that Window that should throw any exceptions, it should work fine. Your Rhino Plugin however will need to have been created with the Checkbox to Use WPF in the Windows UI section of the template. Otherwise the plugin may not be including the necessary references to WindowsBase and PresentationCore which are required for WPF.

I am working with Rhino 7 and .Net framework 4.8.
And package -Microsoft.Xaml.Behaviors.Wpf(version-1.1.39)

Do you have two projects right? one for Rhino and other for GH? It is one depending of the other? To me is not sure how are your dependenicies by your description.

If that works before Rhino/GH loads the plugins you can prevent the dll to be copied to bin by setting Local Copy to false on your dll.

You can also operate on files as Post-build events, for example this instruction copies the rhp in the parent folder as a dll so another project I have can reference it as a dependency, since both can not be in the same folder. In case this helps, just ask ChatGPT for the instructions you need.

xcopy /y "$(TargetDir)StoneTableQA.rhp" "$(TargetDir)..\StoneTableQA.dll"
1 Like