DLL VB.net类程序集,其成员在Delphi xe7中不可见

时间:2015-03-16 03:12:27

标签: vb.net delphi

我正在尝试创建一个用.NET VB编写的测试DLL,其中一个类及其成员要导出到DELPHI XE7,这里是VB代码(在visual studio下免费),我使这个程序集可见COM(检查编译器选项)。

Imports System.Windows.Forms

Namespace prismacdll


    Public Class PrismAcDll

        ' Use the Region directive to define a section named COM Guids. 

#Region "COM GUIDs"
        ' These  GUIDs provide the COM identity for this class  
        ' and its COM interfaces. You can generate  
        ' these guids using guidgen.exe 
        Public Const ClassId As String = "63c6c4d4-6df8-4de8-ac3c-e50ddbce4306"
        Public Const InterfaceId As String = "EA623909-5434-4FEF-B7DD-6D37C1A1D8BF"
        Public Const EventsId As String = "5AECCEBF-DA0B-4209-A16F-2424FB900CF1"


#End Region

        Public Function send_to_astrometry( _
                                     ByVal filepath As String, _
                                     ByVal Api_Key As String, _
                                     ByVal url_Astrometry As String,
                                     ByVal chmp_img As String,
                                     ByVal err_pos As String
                                     ) As String

            Dim result As String = ""
            Try
                MessageBox.Show("FilePath : " & filepath & vbCrLf & _
                            "ApiKey   : " & Api_Key & vbCrLf & _
                            "url_Astro: " & url_Astrometry & vbCrLf & _
                            "chmp_img : " & chmp_img & vbCrLf & _
                            "err_pos  : " & err_pos & vbCrLf, _
                                "Reçu dans la DLL"
                            )

            Catch ex As Exception
            End Try
            Return result

        End Function

        Public Function get_status_from_astrometry( _
                                 ByVal Api_Key As String, _
                                 ByVal url_Astrometry As String,
                                 ByVal Nr_Session As String
                                 ) As String

            Dim result As String = ""
            Try
                MessageBox.Show( _
                    "ApiKey   : " & Api_Key & vbCrLf & _
                    "url_Astro: " & url_Astrometry & vbCrLf & _
                    "Nr_Session : " & Nr_Session & vbCrLf, _
                     "Reçu dans la DLL"
                    )
            Catch ex As Exception

            End Try

            Return result

        End Function

    End Class
End Namespace

我使用/ codebase选项注册了DLL,然后将其作为组件导入Delphi,这是令人失望的结果 - >>

unit PrismAcDll_TLB;

// DepndLst : 
//   (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
//   (2) v2.4 mscorlib, (c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb)
// SYS_KIND: SYS_WIN32
// Errors:


{$TYPEDADDRESS OFF} 
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}

interface

uses Winapi.Windows, mscorlib_TLB, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX;



const

  PrismAcDllMajorVersion = 1;
  PrismAcDllMinorVersion = 0;

  LIBID_PrismAcDll: TGUID = '{63C6C4D4-6DF8-4DE8-AC3C-E50DDBCE4306}';

  IID__PrismAcDll: TGUID = '{0A874332-829E-3551-BA84-C3D1A690D93A}';
  CLASS_PrismAcDll_: TGUID = '{2A3DFA90-9BF2-394E-BD8C-1ED73B3408AB}';
type


  _PrismAcDll = interface;
  _PrismAcDllDisp = dispinterface;


  PrismAcDll_ = _PrismAcDll;


// *********************************************************************//
// Interface :   _PrismAcDll
// Indicateurs : (4432) Hidden Dual OleAutomation Dispatchable
// GUID :        {0A874332-829E-3551-BA84-C3D1A690D93A}
// *********************************************************************//
  _PrismAcDll = interface(IDispatch)
    ['{0A874332-829E-3551-BA84-C3D1A690D93A}']
  end;

// *********************************************************************//
// DispIntf :    _PrismAcDllDisp
// Indicateurs : (4432) Hidden Dual OleAutomation Dispatchable
// GUID :        {0A874332-829E-3551-BA84-C3D1A690D93A}
// *********************************************************************//
  _PrismAcDllDisp = dispinterface
    ['{0A874332-829E-3551-BA84-C3D1A690D93A}']
  end;


  CoPrismAcDll_ = class
    class function Create: _PrismAcDll;
    class function CreateRemote(const MachineName: string): _PrismAcDll;
  end;

implementation

uses System.Win.ComObj;

class function CoPrismAcDll_.Create: _PrismAcDll;
begin
  Result := CreateComObject(CLASS_PrismAcDll_) as _PrismAcDll;
end;

class function CoPrismAcDll_.CreateRemote(const MachineName: string): _PrismAcDll;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_PrismAcDll_) as _PrismAcDll;
end;

end.

似乎Delphi无法看到班级成员 send_to_astrometry和get_status_from_astrometry 我花了很多时间,我无法理解为什么班上的两个成员不可见......

非常感谢。

0 个答案:

没有答案