Rick Strahl's Weblog
Rick Strahl's FoxPro and Web Connection Weblog
White Papers | Products | Message Board | News |

wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

September 27, 2012 •

I'm happy to announce that as of a couple of days ago, wwDotnet Bridge - our library to access .NET components from Visual FoxPro code - is now free and open source. You can find out more wwDotnetBridge here:

What is wwDotnetBridge?

wwDotnetBridge is a library that makes it easy for FoxPro to access .NET code. While there's a native mechanism available to call .NET components via .NET COM Interop, that mechanism is woefully limited to components that are actually registered to COM, which is very few components, except those you create yourself. wwDotnetBridge provides an easy mechanism to access just about any .NET component regardless of whether it's registered to COM or not and provides access to methods and classes that native COM Interop can't handle directly.

wwDotnetBridge provides a custom .NET Runtime host that is loaded into Visual Foxpro. This custom host allows instantiating of .NET Components without requiring COM registration as it manages the instantiation of the runtime and providing a proxy into the .NET framework. wwDotnetBridge still uses COM Interop - the objects you interact with are still COM objects and exhibit the same behaviors as objects used with native COM Interop, but the instantiation process is different going through wwDotnetBridge.

To create custom in wwDotnetBridge you use syntax like this:

loBridge = CreateObject("wwDotNetBridge","V4") 
loFox = loBridge.CreateInstance("InteropExamples.Examples")

So instead of CREATEOBJECT("ComProgId") using wwDotnetBridge involves calling loBridge.CreateInstance("dotnetnamespace.dotnetclass"). Once instantiated the object behaves the same way as one returned from native COM Interop. CreateInstance also allows instantiation .NET classes that have parameterized constructors - the parameters can be passed after the type name of CreateInstance.

Once the wwDotnetBridge instance has been instantiated and any required assemblies have been loaded a bunch of additional functionality becomes available to access on .NET components. One of the most common things you might do with the native classes in the .NET runtime is to access static methods.

For example the following uses the .NET EventLog component to write an entry into the Windows Event Log:

loBridge = CreateObject("wwDotNetBridge","V4")
lcSource = "FoxProEvents"
lcLogType = "Application"
IF !loBridge.Invokestaticmethod("System.Diagnostics.EventLog",;
*** Write out default message - Information
* public static void WriteEntry(string source, string message)
                            "Logging from FoxPro " + TRANSFORM(DATETIME()) )  

This sort of thing was not possible directly with native .NET COM Interop since it only works with types exported to COM. Without wwDotnetBridge, using COM Interop often involved writing a custom .NET component that performed a few tasks like the above and then calling that component from FoxPro via COM interop. With wwDotnetBridge many of these simple tasks can be accomplished directly from within Visual FoxPro code, not requiring you to create any code in .NET. Not that it's a bad idea to create an intermediary .NET assembly for truly complex tasks - sometimes that can be vastly easier to write a little bit of .NET code IN .NET rather than trying to access it all from FoxPro, but for many things that are built into the .NET framework that are abstracted enough it's simply no longer necessary to have to create a separate component.

I don't want to show too many examples here since I covered a ton of them in the wwDotnetBridge White Paper. If you want to see more examples of what wwDotnetBridge can do and how it improves upon native COM Interop the white paper is a great place to start.

Why now?

wwDotnetBridge has been around for quite a while since 2007 and has been a part of West Wind Web Connection and West Wind Client Tools ever since. However, it hasn't exactly gotten the attention I thought it would get,  primarily because it's been buried inside the many fold functionality of these two very rich products. I'm hoping by releasing it as a free standalone component it will show up on more people's radar as they need to expand the reach of their FoxPro applications into new functionality available through .NET.

I created wwDotnetBridge because I had several applications that needed to interface with .NET functionality and the COM registration issues were causing me major issues during installation on some machines. Additionally I continually ran into issues with not being able to access certain .NET objects and members from FoxPro code. After some thought I decided to create an interop library that would help with proxying values back and forth between .NET and FoxPro. What started as a small support library quickly turned into a comprehensive set of components that can fix up many common problem types that don't marshal from .NET FoxPro and back and the end result was wwDotnetBridge. Since then I've been using wwDotnetBridge for all of my COM Interop code from FoxPro.

One product in particular - the West Wind Web Service Proxy Generator for Visual FoxPro - relies heavily on the features of wwDotnetBridge and has also been a source of many, many improvements to the library as it generated a huge variety of different usage scenarios for result .NET types. Whenever there have been problems with specific types I've been able to either find workarounds to access them in FoxPro or - more often than not - provided helper objects that can automatically handle these problem types.

In any case, I've found wwDotnetBridge immensely useful in my FoxPro work, and I'm hoping it'll be useful to some of you as well. If you plan on using .NET functionality in your FoxPro applications, check out wwDotnetBridge - it'll make life a lot easier.

Posted in: FoxPro    .NET    Desktop Apps    COM

Feedback for this Weblog Entry

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

September 30, 2012

WOW ! You are the man Rick !


Just posted the great news in Foxite: http://www.foxite.com/archives/0000356391.htm

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

October 01, 2012

Rick, this is great news--thanks so much for all you do for the VFP community.

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

February 02, 2013

First of all thanks Rick for such tool. I want to know that can we use .net GUI Forms/Controls too with this?

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

Steve Wiley
May 31, 2013

So glad and lucky to have stumbled upon this tool! Not only does your white paper's method of enabling COM Interop in a .NET project easier than any example I've found, it eliminates the need!

Thanks to wwDotnetBridge, it will be a lot easier for my users (and me!) to access my .NET code from an old VFP9 application. I can't thank you enough.

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

Vasim Hanna-Salem
February 20, 2015

I wish more Visual FoxPro developers knew how great this tool is, this is very cool and works great

Thank you so much for making this Free and Open

re: wwDotnetBridge for FoxPro .NET Interop is now Free and Open Source

March 03, 2015


I have one doubt calling CreateClrInstanceFrom function. I have .net dll written in C#.net. I am able create object in vfp, but couldnt run a static function written in C#, throwing unknown name error.

If you have solution please let me know, It helps me a lot. thanks in advance.


© Rick Strahl, West Wind Technologies, 2003 - 2024