r/hamdevs • u/Papkee • Nov 11 '20
Proper way to use OmniRig in C# application?
Hi all!
I'm trying to integrate OmniRig into my C# WPF application.
All of the examples I've found simply include the .exe as a reference in Visual Studio, and reference all the classes and types (OmniRig.OmniRigX, etc) locally.
However, this just creates a local copy of OmniRig as a dll (Interop.Omnirig.dll) in the project directory, and doesn't actually reference the .exe in Program Files. This defeats the purpose of Omnirig, as it's supposed to live in one directory, with all its rig config, and be called by multiple applications (HDSDR, my program, etc). When you run my application, it creates an entirely new instance of OmniRig with a blank config.
I was wondering if anyone had any good examples of the "right way" to reference and use OmniRig in a project. I really wish HDSDR was open-source, because they're doing it the "right way" and I'd love to just be able to take a look.
Sincerely,
A C#/WPF newbie who wants to make his application work right.
EDIT
I'm dumb. Evidently Visual Studio is actually referencing the Program Files install directory for OmniRig. It's just being strange in that the rig name parameter for OmniRig (what I was using to verify things were being loaded properly) isn't being loaded until I actually connect and start listening for data updates.
3
u/2E1EPQ Nov 11 '20 edited Nov 11 '20
The interop DLL isn’t a copy of the DLL, it’s a generated managed facade to the unmanaged DLL.
I’ve started building out NRig, which is an attempt to provide a managed .NET interface over rig control. It’s on GitHub and is a nuget package. I’ve started a hamlib back-end but it would be cool and save others work in future if you fancied writing an Omnirig back end for it...
1
u/loebricator Nov 11 '20
Not familiar with OmniRig, but in Visual Studio you can right click on the referenced library, go to Properties, and then look for the for the property "Copy Local", which I believe by default gets set to True. Flip it false, maybe that will solve your problem?