将Microsoft.Sharepoint.Client.Dll导入Delphi

时间:2016-04-28 11:02:29

标签: c# delphi dll sharepoint-2013 typelib

我正在编写代码来访问Sharepoint以查找和打开文件。我的开发环境是Windows 10 64位和Delphi XE8。

我已下载并安装了SharePoint SDK(sharepointclientcomponents_15-4711-1001_x64_en-us.msi),我现在正尝试导入microsoft.sharepoint.client和microsoft.sharepoint.client.runtime dll' s使用组件>导入组件..向导。

当我尝试将它们作为.net程序集导入时,它们不在初始列表中(可能是因为它们是64位而Delphi只显示GAC_32目录),当我单击Add时,选择DLL对话框关闭但是什么都没发生。 dll不在列表中,并且没有错误消息。

当我尝试导入为TLB时,我得到错误加载类型库/ DLL'并且错误的细节不是特别有用。最后三行是:

[501B8578]{rtl220.bpl  } System.Win.ComObj.OleError (Line 1466, "System.Win.ComObj.pas" + 1) + $11
[21518467]{tlib220.bpl } TlbUtils.LoadTypeLibrary (Line 406, "TlbUtils.pas" + 11) + $2
[21518555]{tlib220.bpl } TlbUtils.LoadAndRegisterTypeLibrary (Line 429, "TlbUtils.pas" + 1) + $7

(如果您想要完整的错误文本发布,请告诉我。)

然后我尝试了RegASM:

regasm.exe Microsoft.SharePoint.Client.dll /tlb > Reg.log 2>&1

我重复了运行时dll,然后我成功地将生成的tlb导入到XE8中。我也必须为“mscorlib”做同样的事情。和&#39;系统&#39; dll要让它编译。<​​/ p>

所以我现在有了我的tlb&#39;但它们似乎只包含接口引用和coclass创建者。他们都没有应该存在的属性和方法。

我已经做了很多研究,并且在这里看到了类似问题的问题,但它们似乎与不正确公开其方法的DLL相关。我假设我们被告知使用的Microsft Sharepoint dll将具有正确的实现,因此这些答案不适用。

在Visual Studio / C#中,我可以添加对相同dll的引用,而不必诉诸于regasm,并且所有属性和方法都存在且正确。我可以在C#中编写一个DLL来暴露我想要的方法,但是我不应该诉诸于此吗?

我已经从运行时tlb中删除了Authentication和LoginResult条目,作为它在Delphi中的外观示例。实际的tlb是2760行,所以有点大可以粘贴到这里!

unit Microsoft_SharePoint_Client_Runtime_TLB;

// ************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //

// $Rev: 52393 $
// File generated on 28/04/2016 09:22:51 from Type Library described below.

// ************************************************************************  //
// Type Lib: c:\Temp\dllreg\Microsoft.SharePoint.Client.Runtime.tlb (1)
// LIBID: {439C353F-FFEE-349C-A9C6-4322906465F7}
// LCID: 0
// Helpfile:
// HelpString: Microsoft.SharePoint.Client.Runtime
// DepndLst:
//   (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
//   (2) v2.4 mscorlib, (C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb)
//   (3) v2.4 System, (C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.tlb)
// SYS_KIND: SYS_WIN32
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}

interface

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


// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
//   Type Libraries     : LIBID_xxxx
//   CoClasses          : CLASS_xxxx
//   DISPInterfaces     : DIID_xxxx
//   Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
  // TypeLibrary Major and minor versions
  Microsoft_SharePoint_Client_RuntimeMajorVersion = 15;
  Microsoft_SharePoint_Client_RuntimeMinorVersion = 0;

  LIBID_Microsoft_SharePoint_Client_Runtime: TGUID = '{439C353F-FFEE-349C-A9C6-4322906465F7}';

  IID__Authentication: TGUID = '{FD87FC16-6D71-3F2A-ACCE-BCC193255B34}';
  IID__LoginResult: TGUID = '{D2AE246E-8C42-35EA-8EBF-2253EE2B1E54}';
...

  CLASS_Authentication: TGUID = '{94FE97EE-7E22-3F9B-AA69-2E9E9A428F19}';
  CLASS_LoginResult: TGUID = '{F8CDCD6E-DED5-3584-AEFE-C4AA74CDFF6D}';
...

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
  _Authentication = interface;
  _AuthenticationDisp = dispinterface;
  _LoginResult = interface;
  _LoginResultDisp = dispinterface;
...

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
  Authentication = _Authentication;
  LoginResult = _LoginResult;
...

// *********************************************************************//
// Interface: _Authentication
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {FD87FC16-6D71-3F2A-ACCE-BCC193255B34}
// *********************************************************************//
  _Authentication = interface(IDispatch)
    ['{FD87FC16-6D71-3F2A-ACCE-BCC193255B34}']
  end;

// *********************************************************************//
// DispIntf:  _AuthenticationDisp
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {FD87FC16-6D71-3F2A-ACCE-BCC193255B34}
// *********************************************************************//
  _AuthenticationDisp = dispinterface
    ['{FD87FC16-6D71-3F2A-ACCE-BCC193255B34}']
  end;

// *********************************************************************//
// Interface: _LoginResult
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {D2AE246E-8C42-35EA-8EBF-2253EE2B1E54}
// *********************************************************************//
  _LoginResult = interface(IDispatch)
    ['{D2AE246E-8C42-35EA-8EBF-2253EE2B1E54}']
  end;

// *********************************************************************//
// DispIntf:  _LoginResultDisp
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {D2AE246E-8C42-35EA-8EBF-2253EE2B1E54}
// *********************************************************************//
  _LoginResultDisp = dispinterface
    ['{D2AE246E-8C42-35EA-8EBF-2253EE2B1E54}']
  end;
...

// *********************************************************************//
// The Class CoAuthentication provides a Create and CreateRemote method to
// create instances of the default interface _Authentication exposed by
// the CoClass Authentication. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
  CoAuthentication = class
    class function Create: _Authentication;
    class function CreateRemote(const MachineName: string): _Authentication;
  end;

// *********************************************************************//
// The Class CoLoginResult provides a Create and CreateRemote method to
// create instances of the default interface _LoginResult exposed by
// the CoClass LoginResult. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
  CoLoginResult = class
    class function Create: _LoginResult;
    class function CreateRemote(const MachineName: string): _LoginResult;
  end;
...

implementation

uses System.Win.ComObj;

class function CoAuthentication.Create: _Authentication;
begin
  Result := CreateComObject(CLASS_Authentication) as _Authentication;
end;

class function CoAuthentication.CreateRemote(const MachineName: string): _Authentication;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_Authentication) as _Authentication;
end;

class function CoLoginResult.Create: _LoginResult;
begin
  Result := CreateComObject(CLASS_LoginResult) as _LoginResult;
end;

class function CoLoginResult.CreateRemote(const MachineName: string): _LoginResult;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_LoginResult) as _LoginResult;
end;

...
end;

我怀疑这可能至少部分是32/64位问题,但我真的不知道。

提前感谢您的任何帮助:)

0 个答案:

没有答案
相关问题