foxpro dll breaking when region settings are changed

Posted on 2011-10-31
Last Modified: 2012-06-21
I have a foxpro dll that that accepts 2 string Parameters.
I am calling it from a VB6 dll
when I compile the foxpro dll under US region settings and run my application everything is fine.
However when i change region settings to Canada i get the following errors
Class does not support Automation or does not support expected interface GetFilez/Line 5

If i recompile while set to Canadian settings it all works fine but when I switch to USA region Settings same error as above

vb6 coded
4     Dim oNMS As New clsNMS.COPYFILES
5     bCopyFiles = oNMS.getfilez(Trim(sPMSPath), Trim(WorkingFolder))

Foxpro Code
		DECLARE Sleep IN kernel32 INTEGER dwMilliseconds
		Sleep (5000)
End Function

Open in new window

Question by:hainansyndrome
    LVL 29

    Expert Comment

    by:Olaf Doschke
    Never heard of regional setting having an influence on the automation support.

    Do you compile in VFP with regenerting Component IDs? Then you need to reregister OLE classes and VB may have the old ones still in "mind". Eg in VBA you need to add references to OLE classes and those References get invalid, if the component IDs change.

    Region dependant registration doesn't make any sense, I`ve no idea where this could play a roll.

    Try to turn off regenerating copmponent IDs, then compile once again, add refereneces to VB and then see if recompilation renders the dll useless again or not.

    Another thing: You can't recompile and replace a DLL, as long as it's in use. That might also play a role in rendering the foxpro DLL useless and the observation of regional setting was perhaps just coincidential.

    Bye, Olaf.

    Author Comment

    I make sure the dll's are not in use.
    the thing is it works when I switch my region settings back to the zone that the DLL's were compiled in

    on the foxpro dll
    i am using VFP 6

    I do not have regenerate ComponentIDs checked, so no i dont
    LVL 29

    Expert Comment

    by:Olaf Doschke
    I just don't see how region settings would influence an ole class being automatiable or not, other than it might influence on what you and your VB code sees in the registry. But the registry also isn`t depending on region settings.

    The region setting can influence what resource DLL of the runtime is used. I'm not aware of a canadian version, default always is the enu dll vfp6renu.dll. There is no canadian english or british english resource file.

    Bye, Olaf.

    Author Comment

    i dont think the vb6 code plays in anywhere
    it gets to the same point reguardless of compile or region settings
    5 bCopyFiles = oNMS.getfilez(Trim(sPMSPath), Trim(WorkingFolder))
    it is always when calling into the foxpro dll that the error occurs

    LVL 29

    Expert Comment

    by:Olaf Doschke
    I didn't say it's the VB code. It's neither a VB code nor a Fox code issue. If the class or it's interface isn't found it would rather be a OS issue. Or registry. And the component IDs are what would play a role there.

    regional settings only have influence of what language resource runtime DLL of foxpro is used. But even if one is missing the deafult enu dll would be used.

    I daon't know what else would play a role.

    Maybe time to analize the problem via tools. Process monitor could say more about what's going on, when the VB code hits the line calling the fox COM object.

    Bye, Olaf.

    Author Comment

    i tried all of that and I cant figure it out
    nothing is working
    I am even trying other machines to make sure
    LVL 29

    Expert Comment

    by:Olaf Doschke
    Things that "Class does not support Automation or does not support expected interface" mean:

    1. "does not support Automation"
    Well, obviously wrong, but maybe a registration issue. At least the class is know, otherwise an error would be "class definition not found".

    2. "does not support expected interface"
    The typelib of an ole class defines an interface, mostly that is: a) what method names and b) what parameterisation
    are offered by the ole class.

    If it's an issue between expected and real interface, that could be due to changes. But you say you simply change region and not any code, so there is no difference in registered vs real interface.

    Again the culprit may again be the registration.

    You are doing early binding in VB. What you could try is:
    Dim oNMS As Object
    oNMS = CreateObject("clsNMS.COPYFILES")
    bCopyFiles = oNMS.getfilez(Trim(sPMSPath), Trim(WorkingFolder)

    Which would be late binding.

    Bye, Olaf.

    Accepted Solution

    I figured it out
    I feel stupid

    the end of my function i was typeing END Function

    IF i changed it to ENDFUNC it worked
    LVL 29

    Expert Comment

    by:Olaf Doschke
    END or END FUNCTION indeed will not work out, END FUNCTION leads to compile error "unrecognized phrase/keyword".

    Indeed ENDFUNC is as optional as is ENDPROC. Foxpro does not need an end delimiter for procedures or functions, the next  PROCEDURE or FUNCTION is both end of previous and start of the next procedure/function.

    As your code did compile, I thought of it as a posting error, you can't compile that without getting an error.

    Besides, revisiting and reinspecting your code - Foxpro does only make a difference between FUNCTION and PROCEDURE as stand alone constructs. In a class we talk of methods and foxpro stores all methods as PROCEDURE, not as FUNCTION (take any visual class in the class browser and use the "viewcode" button and you'll see, dito if you open a vcx as table and look into the code memo) , but indeed in a prg class definition with DEFINE CLASS FUNCTIONs also work out as methods.

    Bye, Olaf.
    LVL 53

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    A short article about problems I had with the new location API and permissions in Marshmallow
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now