Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs
Contact   •   Articles   •   Products   •   Support   •   Search
Ad-free experience sponsored by:
ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more

Advanced FoxPro .NET COM Interop Article Series


:P
On this page:

I've put up a three part article series on advanced FoxPro and .NET Interop topic dealing with handling complex object passing, handling .NET COM events and multi-threading with .NET components. This entry serves as a discussion placeholder for these three articles, so you can leave comments and questions below.

The actual articles can be found here:

   1. Passing objects between FoxPro and .NET COM Components
   2. Handling .NET Events in FoxPro via COM Interop
   3. Creating multi-threaded components .NET for COM Interop with Visual FoxPro

This article is a follow up for the original base article that discussed the basic concepts of COM Interop:

   Using .NET Components via COM from Visual FoxPro

Enjoy...

 

 


The Voices of Reason


 

Mukesh
January 09, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Sir
I want to know that can i build a VFP DLL that will create a Excel/ Powerpoint document. this DLL will be called from a .NET Web Page on click of a button. This will generate a Excel /Powerpoint Document on web server and available to user as a hyperlink on the web page.

Please reply to my email id muk944@yahoo.com
i will be highly grateful to you

thanks

Rick Strahl
January 23, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

There are lots of problems passing arrays over COM. The biggest issue I know of is changing a COM array in VFP, which is a pain and sometimes doesn't work at all. Usually what you have to do is re-write the entire array to make it work.

There are many scenarios here and many don't work as you would expect, but a combination of COMARRAY and copying the elements and re-writining them gets you around most of them.

Finally if you have a choice in the matter use Collections to pass data rather than arrays. Collections are real objects and it's easier for .NET and Fox both to deal with this type of COM data.

Mikhail Mitiaguin
January 23, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Just wondering are there any complications with foxpro arrays.
There seem to be a problem when array is redimensioned or expression for the size is used when declared.

Fox

LOCAL ARRAY col_names[getwordcount(tbl_fields,',')] as String
oBuilder = createobject ( ... )
comarray(( oBuilder, 10 )
oBuilder.Buildindex( @col_names )


Net
public string BuildIndex( string[] columns )

It works OK when array size in Fox is constant.
Using ref C# or changing to passing by value doesn't really help.

Ralf Dörfel
January 31, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Dear Rick,

I am having problems with a COM-Server of a CAD software. A function needs a zero based array, as known FP-arrays always start with index 1, but I have no influence on the server.
Do you have an idea?

Best regards and thank you in advance,
Ralf Dörfel from germany

Ralf Dörfel
February 02, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Hi Rick,
ok I have found your article :-):
http://west-wind.com/weblog/posts/2328.aspx
But I am having the problem with a [m,n] dimensioned array and it still crashes.
Greetings,
Ralf Dörfel from Germany

Curtis
July 17, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Rick,

Thanks for the great article I'm using VFP 7 though and having trouble getting the hardcoded path to the type library in the "Implements IN" parameter changed the the COM progid. Foxpro says it can't find the type library when I change it to the progid any suggestions as to what I am doing wrong?

Thanks,
Curtis

Rick Strahl
July 25, 2006

# re: Advanced FoxPro .NET COM Interop Article Series

Probably not supported in VFP 7...

In 8 and 9 you can use the ProgId of any COM object that's located in the same binary/type library and VFP will find it.

Rick Strahl's Web Log
November 12, 2006

# Passing Arrays to a .NET COM object from Visual FoxPro - Rick Strahl's Web Log

Passing arrays from VFP over COM is always a tricky affair because VFP arrays require some special marshalling hints in order to properly translate. This entry shows how to pass VFP arrays to .NET and retrieve array results from .NET COM objects.

# DotNetSlackers: Advanced FoxPro COM Interop Article Series


Paul
August 07, 2007

# re: Advanced FoxPro .NET COM Interop Article Series

Great job, Rick!
I'm using VFP 9,
Thanks for the great article!

Allard
December 19, 2007

# re: Advanced FoxPro .NET COM Interop Article Series

Thanks Rick, this article got me started using vb.net code from our existing fox application. There is one thing I cannot figure out (maybe not possible at all, but maybe you know). If you are launching forms created in .net modeless (using a separate thread), how do you make this form owned by the main foxpro form?

Viktor
May 06, 2008

# re: Advanced FoxPro .NET COM Interop Article Series

Dear Rick!

I have this "Type Library Not Foun" too. I'm using VFP9 SP2. Could you help me with some clues? I have none.

Thanks in advance!

Viktor

ps.: simple calls to COM exposed .NET functions work fine, but implementing the interface dies when giving the IMPLEMENTS... part.

Robert
September 24, 2008

# re: Advanced FoxPro .NET COM Interop Article Series

Hi Rick
I have a FOX COM using in ASP.NET, and is ok in Windows 2000, but in Windows 2003 when I try return an error : Exception HRESULT: 0x80010105 (RPC_E_SERVERFAULT). There is any special config for FOX COM use in Windows 2003 ? I try with an sample COM with only one Method Hello Word and return error too, but that same code in Windows 2000 work fine .
thanks
Robert

P.J.
May 14, 2009

# re: Advanced FoxPro .NET COM Interop Article Series

Immensely helpful series of articles. However, I am having same problem as Viktor.

This works fine:
oInterop = createobject("PocketSIMS.Interop")


Next part works fine on development machine, but gives "Type Library PocketSIMS.Interop not found" error on client machine:
DEFINE CLASS InteropStatusEvent AS session OLEPUBLIC
    IMPLEMENTS IPocketSIMSEvents IN "PocketSIMS.Interop"

...
    
ENDDEFINE


What am I doing wrong?

P.J.
May 15, 2009

# re: Advanced FoxPro .NET COM Interop Article Series

I think I've got it working. I hadn't included the TLB file on the client.

Dave
December 11, 2009

# re: Advanced FoxPro .NET COM Interop Article Series

Hello Rick,

I've come upon your article as a result of searching (in vain) for a good example showing how to expose events from a managed c# object through COM interop services to be subscribed to and handled in an unmanaged C++ client.

Your article gives me some ideas to try but it's clearly different than what I am doing. I'm having trouble with getting the correct event declaration in the interface section of the managed object and then seeing and subscribing to it in the C++ code.

Do you by chance have any pointers?

Thanks.

amir
March 09, 2010

# re: Advanced FoxPro .NET COM Interop Article Series

hi rick
i faced with this question that is it possible for us to write com capable components in dot net and register it then this com component act as for example chat server for us?(server keep running this component and our com component listen to special port and perform our desired actions)

Rick Strahl
March 09, 2010

# re: Advanced FoxPro .NET COM Interop Article Series

Yes that should be possible. You can host a WCF service in an EXE or COM accessible assembly through VFP (although I would probably recommend using a separate EXE daemon rather than a COM hosted component for stability).

Luis Santos
October 08, 2010

# re: Advanced FoxPro .NET COM Interop Article Series

Hi Rick.
Very good article.

I want to include a .NET form (Not a window) inside a existing FOX PRO form.
Can you give-me some info in order to achieve this?


Best Regards,
Luis Santos

Luis Santos
October 15, 2010

# re: Advanced FoxPro .NET COM Interop Article Series

Hi.

I found this example http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx .

But my Fox Application give-me a the error "OLE error code 0x80020006" when i try to resize the
window.

Pageframe1.Page2.AddObject("myctrl2","olecontrol","Com.example")
Pageframe1.Page2.myctrl2.Visible = .T.
Pageframe1.Page2.myctrl2.width = 400
Pageframe1.Page2.myctrl2.height= 400
.

Can you help-me?

Jaime Galarza
January 28, 2015

# Advanced FoxPro .NET COM Interop Article Series

Dear Rick, sorry for my english, i have a program in VFP 9, the program call a dll in .NET, this dll return 0 or 1 when execute, but aditionally return too different values, here is my problem, i can't capture this values. Please, i need you help .

This is the code:

do wwDotNetBridge
LOCAL loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge")

*** Load our custom assembly and check for errors
IF !loBridge.LoadAssembly("FusionClass.dll")
? loBridge.cErrorMsg
ENDIF

loFusion = loBridge.CreateInstance("FusionClassInterop.FusionInterop")
IF loBridge.lError
? loBridge.cErrorMsg
ENDIF

public status1,statusreturn,substatus,totalbombas,servimode,cade
STORE 0 TO totalbombas
STORE "" TO status1,substatus,servimode,cade
STORE .f. TO statusreturn
** Conectar

*!* loFusion.FusionConnect(&ConfsetIpFusion)
statusreturn = loFusion.FusionConnect("192.168.1.20")

*!* Here is my problem, how i can capture the value of the variable status1
statusreturn = loFusion.ForecourtStatus(status1)
?? status1

hassan
October 04, 2017

# re: Advanced FoxPro .NET COM Interop Article Series

Hi, I've created a DLL COM object in Foxpro and want to use it in ASP.NET Core, so far I've been unable to find a solution and packaging it with Nuget didn't work either whereas I can use this same dll easily in standard ASP.NET. Is there any way to use a Foxpro DLL COM object in ASP.NET Core? or Is there any difference between ASP.NET Core and ASP.NET in using COM objects?

Thanks


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2020