QueryInterfface() in D2007 fails to see Oxygene VisualPlugin interface

I followed the instructions here
http://wiki.remobjects.com/wiki/Passing_interfaces_between_Host_and_Plugins
for passing a message from my Delphi 2007 host to my Oxygene WPF VisualPlugin. The Hydra menu Import Interfaces opened the DLL and found the interface and created a file for it in the Delphi app. The Delphi app loads and shows the contents of the visual plugin in the panel I’m feeding it.

Unfortunately, it fails on the QueryInterface call (with e_nointerface error code). Any suggestions?

This is a very simple test app that’s just using the IMessageProcessor interface like in the example.

Nobody?

Sorry about the late reply.

Do the samples work for you?

The unmanaged host/managed plugin sample shows exactly this. Besides that, how does the code that fails look?

It looks like your project misses a wrapper for wpf plugin, please take a look at following link.

Thanks, folks. I finally got it all figured out. Yes, it was the visual wrapper thing. But even when I found that section, it took a bit for me to get it right. For posterity, here’s what I wound up with:

namespace HydraGuestTest;

interface

uses
  System.Windows,
  System.Windows.Controls,
  System.Windows.Data,
  System.Windows.Documents,
  System.Windows.Media,
  System.Windows.Navigation,
  System.Windows.Shapes,
  RemObjects.Hydra,
  RemObjects.Hydra.WPF,
  RemObjects.Hydra.WPF.Internal,
  RemObjects.Hydra.CrossPlatform,
  System.Runtime.InteropServices,
  RemObjects.Hydra.WPF.Internal;

type
  [Guid('45130519-B022-4528-996A-3F2A2E8A4672')]
  IMessageProcessor = public interface(IHYCrossPlatformInterface)
    method ProcessMessage(Message: String);
  end;

  [Guid('1D5B9648-30A7-4611-A777-80BE07E70EA1')]
  PluginWrapper = public class(VisualPluginWrapper, IMessageProcessor)
  private
    property PluginInstance: Plugin read Plugin(inherited PluginInstance);
  public
    method ProcessMessage(Message: String);
  end;

  [Plugin(), VisualPluginAttribute(), NeedsManagedWrapper(typeOf(PluginWrapper))]
  Plugin = public partial class(RemObjects.Hydra.WPF.VisualPlugin, IMessageProcessor)
  private
    method Button_Click(sender: System.Object; e: System.Windows.RoutedEventArgs);
  public
    constructor;
    method ProcessMessage(Message: String);
  end;
  
implementation

constructor Plugin;
begin
  InitializeComponent();
end;

method Plugin.ProcessMessage(Message: String);
begin
  DisplayLabel.Content := Message;
end;

method Plugin.Button_Click(sender: System.Object; e: System.Windows.RoutedEventArgs);
begin
  (Host as IMessageProcessor).ProcessMessage((new DateTime).Now.ToString);
end;

method PluginWrapper.ProcessMessage(Message: String);
begin
  PluginInstance.ProcessMessage(Message);
end;
  
end.

And the xaml:

<hydra:VisualPlugin x:Class="HydraGuestTest.Plugin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:hydra="clr-namespace:RemObjects.Hydra.WPF;assembly=RemObjects.Hydra.WPF"
    Height="300" Width="300"
    Background="LightYellow"
    >
  <StackPanel Orientation="Vertical">
    <Button Content="A Button!" Click="Button_Click"/>
    <Label x:Name="DisplayLabel" Content="A Label!"/>
  </StackPanel>
</hydra:VisualPlugin>