简体   繁体   English

如何获取已从.Net dll中的FoxPro自定义类创建的对象的属性?

[英]How to get properties of object which has been created from FoxPro custom class in .Net dll?

This is my FoxPro class: 这是我的FoxPro类:

DEFINE CLASS clscem AS custom


Height = 102
Width = 212
publicproperty = "this is my initial value"
pubprop = ""
Name = "clscem"


ENDDEFINE

and this is my form1.scx code: 这是我的form1.scx代码:

objSinif = CREATEOBJECT("SinifDeneme.Class")
donenObjSinif = objSinif.f_Metot(thisform.CLSCEM1)
thisform.command1.Caption = donenObjSinif.M_SitringProp

I am calling .NET dll as COM object from FoxPro. 我正在从FoxPro调用.NET dll作为COM对象。 This is my .NET class of DLL: 这是我的.NET DLL类:

using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;

namespace ClsLib
{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("SinifDeneme.Class")]
    [ComVisible(true)]
    public class Sinif
    {
        public string SitringField;
        public string M_SitringProp { get; set; }
        public Sinif f_Metot(object oj)
        {
            StreamWriter sw = File.CreateText(Path.GetDirectoryName(Assembly.GetAssembly(typeof(Sinif)).Location )+ "\\obje.txt");

            Type myObjectType = oj.GetType();

            //Get public properties
            PropertyInfo[] propertyInfo = myObjectType.GetProperties();
            sw.WriteLine("------------- PROPERTY --------------");
            foreach (PropertyInfo info in propertyInfo)
            {
                sw.WriteLine("Name:"+info.Name);
                sw.WriteLine("PropertyType:"+info.PropertyType);
                sw.WriteLine("GetValue():" + info.GetValue(oj,null));
                sw.WriteLine("-------------");
            }

            FieldInfo[] fieldInfo = myObjectType.GetFields();
            sw.WriteLine("------------- FIELDS --------------");
            foreach (FieldInfo info in fieldInfo)
            {
                sw.WriteLine("Name:" + info.Name);
                sw.WriteLine("AssemblyQualifiedName:" + info.FieldType.AssemblyQualifiedName);
                sw.WriteLine("GetValue():" + info.GetValue(oj));
                sw.WriteLine("-------------");
            }

            sw.Flush();
            sw.Close();
            sw.Dispose();



            return new Sinif()
                   {
                       M_SitringProp="SitringProp propertisi",
                       SitringField="Sitring fieldı"
                   };
        }
    }
}

oj参数QuickWatch屏幕Oj参数的GetType()方法

But I couldn't write the properties or fields of FoxPro object. 但是我无法编写FoxPro对象的属性或字段。 Whereas I can set the property of C# object whicj was returned by f_Metot of DLL. 鉴于我可以设置C#对象的属性,而whi是由DLL的f_Metot返回的。 Where is the problem to get object properties which is coming from FoxPro? 获取来自FoxPro的对象属性的问题在哪里?

I don't know the COM object conversion. 我不知道COM对象转换。 Would you please explain? 你能解释一下吗?

Thanks in advance.... 提前致谢....

里克·斯特拉尔(Rick Strahl) 在VFP和.Net之间的互操作方面了三篇文章 -尽管它有些陈旧,但我希望您能在其中一个(也许是第一个)中找到答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检查从哪个 Class 创建了 object - Check from which Class the object has been created c# dot net core中如何识别一个从.DLL文件转换过来的excel文件(xls, xlsx, csv) - How to identify an excel file(xls, xlsx, csv) which has been converted from .DLL file in c# dot net core 如何获取已传递给方法的类 - how can I get which class has been passed to method 如何通知已从中调用方法的对象 - How to notify object from which a method has been called 从.NET验证一个DLL具有有效的签名并且没有被修改 - From .NET verify a dll has valid signature and has not been modified 如何访问和使用在WPF中的不同线程上创建的对象 - How to access & use an object which has been created on a different thread in WPF 如何从.NET ZipPackage中的文件获取文件属性(创建和修改)? - How to get file properties (Created and Modified) from files in a .NET ZipPackage? 使用通过ILMerge创建的库中的程序集 - Use assembly from a library which has been created through ILMerge 如何知道已创建哪个LiteDB版本DB文件? - How to know with which LiteDB version DB file has been created? 如何初始化动态创建的数组对象? - How to initialize objects of array which has been created dynamically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM