The NET4COM library is a collection of COM classes that wrap a subset of the .NET Framework 2.0. The .NET Framework is a rich collection of namespaces and API that provides a comprehensive set of functionality that developers can use to build applications that run on the .NET platform. While VFP does have a rich library of API, there are some features that either do not exist in the VFP libraries or are harder to use than in the Framework. NET4COM brings together a small subset of the .NET Framework — a collection of commonly used API that brings to VFP functionality that does not exist.
The NET4COM folder contains the following:
- NET4COM.dll -- The DLL for the COM components that wrap a subset of the .NET Framework 2.0.
- Source -- Folder containing project file and source code for NET4COM
- VFPSamples -- Folder containing VFP sample code that uses NET4COM
- VB6Samples -- Folder containing VB6 sample code that uses NET4COM
- FFC -- FFC wrappers for NET4COM
The samples demonstrate use of NET4COM from Visual FoxPro or Visual Basic 6.0.
Note that the Sedna installer doesn’t quite install NET4COM correctly. While the installer registers it as a COM component, it doesn’t generate or register a type library (TLB file) for the DLL, so you can’t register NET4COM with the VFP IntelliSense Manager to get IntelliSense on the classes in NET4COM. Fortunately, there’s a simple fix. Register.BAT, listed below, properly registers NET4COM. Copy this text, paste it into a text file named Register.BAT, and edit the paths if you’ve changed the default installation location for Sedna. Also note that you must run Register.BAT as administrator (right-click the file and choose Run as Administrator) since registering COM components requires administrative privileges. Here’s the content of Register.BAT; the PAUSE statement is there so you can see the messages RegAsm produces indicating success or not:
rem First unregister
C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe "C:\Program Files\Microsoft Visual FoxPro 9\Sedna\NET4COM\NET4COM.dll" /u
rem Now re-register to generate TLB
C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe "C:\Program Files\Microsoft Visual FoxPro 9\Sedna\NET4COM\NET4COM.dll" /codebase /tlb
Note that you will see a warning about registering an unsigned assembly; you can ignore that warning.
After running Register.BAT, open the IntelliSense Manager from the Tools menu, select the Types page, click Type Libraries, then turn on the checkbox in front of “COM Library Wrappers for Microsoft .NET Framework” in the reference list, and click Done (you may have to click the Refresh button in the Type Libraries dialog to ensure this type library appears). You can then type “LOCAL SomeVariable AS NET4COM.” and choose the desired class to get IntelliSense on that class.