Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create a .NET DLL for VFP use
Message
De
07/11/2013 14:18:20
 
 
À
07/11/2013 13:30:18
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01587470
Message ID:
01587515
Vues:
57
>>>>>>Hi All,
>>>>>>We need a .NET dll, it should work with VFP. Our developer generates .NET DLL but VFP cannot see that DLL. That doesn't matter .COM .DLL or not. Just work with VFP enough for us... What he should do when generates DLL for VFP?
>>>>>
>>>>>Should be straightforward. Create a .NET class library. e.g:
namespace ClassLibrary1
>>>>>{
>>>>>    [ClassInterface(ClassInterfaceType.AutoDual)]
>>>>>    [ProgId("Class1Library.Class1")]
>>>>>    public class Class1
>>>>>    {
>>>>>        [ComVisible(true)]
>>>>>        public string Doit()
>>>>>        {
>>>>>            return "Hello World";
>>>>>        }
>>>>>    }
>>>>>}
In the project 'Properties/Application' page click 'Assembly Information' button and make sure 'Make assembly COM visible' is checked. Build the application. If all is well then Class1Library.Class1 should appear in the registry.
>>>>>
>>>>>In VFP:
object = CREATEOBJECT("Class1Library.Class1")
>>>>>? object.Doit()
Note I deliberately made this a bit more complicated than ness. in that I've defined a ProgId that is different to the Class namespace.
>>>>
>>>>Viv
>>>>
>>>>How would one register the class if it had been built on another machine?
>>>
>>>You would need to use regasm.exe : http://msdn.microsoft.com/en-us/library/tzat5yw6(v=vs.110).aspx
>>>(Does the same type of thing as regsvr32 but specifically for .NET assemblies...)
>>Thanks, Viv
>
>You can also set it up to use registrationless COM:
>1) Create a "VFPApp.exe.manifest" text file in the directory where you will be building your application where VFPApp.exe is the name of your VFP executable.
>2) Put the following contents in the file (where DotNetLibrary.dll is your .NET dll, and you'll need to determine the publicKeyToken value). Remove the spaces after the less than symbols:
>
< ?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>< assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
>   manifestVersion="1.0">
>< assemblyIdentity
>            type = "win32"
>            name = "VFPApp.exe"
>            processorArchitecture="x86"
>            version = "1.0.0.0" />
>< dependency>
>            < dependentAssembly>
>                        < assemblyIdentity
>                                    type="win32"
>                                    name="DotNetLibrary"
>									processorArchitecture="x86"
>                                    version="1.0.0.0" 
>									publicKeyToken="MyKeyTokenValue"/>
>            < /dependentAssembly>
>< /dependency>
>< /assembly>
>
>3) Build your VFP application to the directory with the manifest file.
>4) Place the .NET dll in the same directory as the VFP application. You don't need to distribute the manifest file.
>
>The same process should work for other COM dlls as well. Note that if the dll file is missing, you won't be able to run the application, and will receive a side by side configuration error.

Thanks, Rob
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform