加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在Delphi程序中托管.NET运行时

发布时间:2020-12-15 10:09:29 所属栏目:大数据 来源:网络整理
导读:我正在研究使用Delphi程序中的一些.NET代码,我将需要使用.net程序集和预定义函数(我已经支持常规DLL)使程序可扩展. 经过大量的在线搜索后,我发现了Managed-VCL,但是我还没有准备好支付250美元,因为我需要的,我还发现一些新闻组的代码不完整,不起作用. 我在使
我正在研究使用Delphi程序中的一些.NET代码,我将需要使用.net程序集和预定义函数(我已经支持常规DLL)使程序可扩展.

经过大量的在线搜索后,我发现了Managed-VCL,但是我还没有准备好支付250美元,因为我需要的,我还发现一些新闻组的代码不完整,不起作用.

我在使用Delphi 2007 for win32.我可以使用什么来从具有预定义参数的程序集中动态执行函数?

就像是:

procedure ExecAssembly(AssemblyFileName:String; Parameters: Variant);

我只是想补充说,我需要加载一个任意的程序集(也许所有的程序集在一个特定的文件夹),所以创建一个C#包装可能不起作用.

解决方法

在绝地代码库(JCL) – 免费 – 有一个JclDotNet.pas,包含一个类TJclClrHost,可能做你想要的:
TJclClrHost = class(TJclClrBase,ICorRuntimeHost)
  private
    FDefaultInterface: ICorRuntimeHost;
    FAppDomains: TObjectList;
    procedure EnumAppDomains;
    function GetAppDomain(const Idx: Integer): TJclClrAppDomain;
    function GetAppDomainCount: Integer;
    function GetDefaultAppDomain: IJclClrAppDomain;
    function GetCurrentAppDomain: IJclClrAppDomain;
  protected
    function AddAppDomain(const AppDomain: TJclClrAppDomain): Integer;
    function RemoveAppDomain(const AppDomain: TJclClrAppDomain): Integer; 
  public
    constructor Create(const ClrVer: WideString = '';
      const Flavor: TJclClrHostFlavor = hfWorkStation;
      const ConcurrentGC: Boolean = True;
      const LoaderFlags: TJclClrHostLoaderFlags = [hlOptSingleDomain]);
    destructor Destroy; override;
    procedure Start;
    procedure Stop;
    procedure Refresh;
    function CreateDomainSetup: TJclClrAppDomainSetup;
    function CreateAppDomain(const Name: WideString;
      const Setup: TJclClrAppDomainSetup = nil;
      const Evidence: IJclClrEvidence = nil): TJclClrAppDomain;
    function FindAppDomain(const Intf: IJclClrAppDomain; var Ret: TJclClrAppDomain): Boolean; overload;
    function FindAppDomain(const Name: WideString; var Ret: TJclClrAppDomain): Boolean; overload;
    class function CorSystemDirectory: WideString;
    class function CorVersion: WideString;
    class function CorRequiredVersion: WideString;
    class procedure GetClrVersions(VersionNames: TWideStrings); overload;
    class procedure GetClrVersions(VersionNames: TStrings); overload;
    property DefaultInterface: ICorRuntimeHost read FDefaultInterface implements ICorRuntimeHost;
    property AppDomains[const Idx: Integer]: TJclClrAppDomain read GetAppDomain; default;
    property AppDomainCount: Integer read GetAppDomainCount;
    property DefaultAppDomain: IJclClrAppDomain read GetDefaultAppDomain;
    property CurrentAppDomain: IJclClrAppDomain read GetCurrentAppDomain;
  end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读