RTTI 不足,无法支持此操作 - Delphi XE6 - 网络共享组件

问题描述 投票:0回答:1

我使用了 Delphi 的网络共享组件来实现我的一个想法。一切都很好,除非您决定构建 EXE。全新构建后启动时出现此错误:

这只发生在全新构建之后。如果我再次编译应用程序,问题就会消失并且一切正常。一旦我构建应用程序并调试代码,它就会给我一个关于此作业的错误:

 TetheringAppProfile := TTetheringAppProfile.Create(nil);  
  with TetheringAppProfile do
  begin
    Manager            := TetheringManager; //This line
    Text               := 'AppTether';
  end

为了尝试解决此问题,我决定将代码移动到一个包中,这样每次构建 EXE 时都不会重新编译。这个想法听起来很酷,但行不通,这让我感到困惑。我所做的就是实现我在这里找到的想法:高级动态包

它向您展示了如何使用您自己的自定义方法在代码中动态加载包。我用的是第一个例子。我实现了一个基础包,其中包含我想要调用的所有方法。该包作为运行时包包含在内。然后我添加了另一个包,其表单需要基础包但单独分发。我的思考过程是,如果我可以构建主 EXE 并且其他代码保持不变,那么这个问题就不会发生。但是不,当我重建我的主 exe 时,出于某种原因,我仍然收到该错误。如果我重建在代码中动态加载的一个包,然后重新运行主 exe 而不做任何进一步的操作,它就会起作用。为什么?

我已经四处寻找此错误,但没有在哪里找到通过 XE6 中的网络共享组件遇到此问题的人。

这是调用堆栈:

exception class    : EInsufficientRtti
exception message  : Insufficient RTTI available to support this operation.

main thread ($4d60):
004c17a2 +000e JAM.exe      System.Rtti                             CheckCodeAddress
004ce740 +0508 JAM.exe      System.Rtti                             TRttiInstanceMethodEx.DispatchInvoke
004d7f5c +0044 JAM.exe      System.Rtti                             TRttiMethod.Invoke
010d4701 +017d JAM.exe      IPPeerAPI                               TIPPeerFactory.CreatePeer
012258c9 +0051 JAM.exe      System.Tether.NetworkAdapter            TTetheringNetworkAdapter.Create
0122592f +0007 JAM.exe      System.Tether.NetworkAdapter            TTetheringNetworkAdapter.CreateInstance
011ffa6d +0019 JAM.exe      System.Tether.Manager                   TTetheringAdapters.GetAdapterInstance
011fb98e +004a JAM.exe      System.Tether.Manager                   TTetheringManager.AutoCreateAdapters
011fdce2 +0016 JAM.exe      System.Tether.Manager                   TTetheringManager.RegisterProfile
011ff0d7 +0023 JAM.exe      System.Tether.Manager                   TTetheringProfile.SetManager
0126f62a +004e JAM.exe      uTetherPackage                  47  +11 TTetherPackage.CreateTetherComponents
01270283 +003f JAM.exe      uTetherings                    146   +6 TTetherings.CreateTetherings
01942794 +1210 JAM.exe      uMain                         1031 +321 TfrmMain.FormCreate
00686f2d +0031 JAM.exe      Vcl.Forms                     3745   +3 TCustomForm.DoCreate
00686b31 +0011 JAM.exe      Vcl.Forms                     3628   +1 TCustomForm.AfterConstruction
00409bd9 +001d JAM.exe      System                         492   +0 @AfterConstruction
00686ae3 +019b JAM.exe      Vcl.Forms                     3618  +35 TCustomForm.Create
00691546 +0076 JAM.exe      Vcl.Forms                    10470  +13 TApplication.CreateForm
01990d87 +0307 JAM.exe      JAM                           1469 +113 initialization
76d07c02 +0022 KERNEL32.DLL                                         BaseThreadInitThunk

thread $643c:
76621129 +000 KERNELBASE.dll           WaitForMultipleObjectsEx
76ffde8d +15d user32.dll               MsgWaitForMultipleObjectsEx
76ffdbda +01a user32.dll               MsgWaitForMultipleObjects
004aaa15 +00d JAM.exe        madExcept CallThreadProcSafe
004aaa7a +032 JAM.exe        madExcept ThreadExceptFrame
76d07c02 +022 KERNEL32.DLL             BaseThreadInitThunk
>> created by main thread ($4d60) at:
6d8ae04a +000 gdiplus.dll

thread $587c (TDMSThread):
76612cc1 +b1 KERNELBASE.dll                        WaitForSingleObjectEx
76612bfd +0d KERNELBASE.dll                        WaitForSingleObject
010adb07 +1b JAM.exe        uSignalFlag      54 +3 TSignalFlag.WaitForSignal
010ba90d +49 JAM.exe        uDMSWriter     1672 +7 TDMSThread.Execute
004aab2f +2b JAM.exe        madExcept              HookedTThreadExecute
0052a371 +49 JAM.exe        System.Classes         ThreadProc
0040b230 +28 JAM.exe        System          492 +0 ThreadWrapper
004aaa15 +0d JAM.exe        madExcept              CallThreadProcSafe

当我尝试进入给出错误的行时,它会将我带到 System.Generics.Collections 到此方法:

function TEnumerable<T>.ToArrayImpl(Count: Integer): TArray<T>;
var
  x: T;
begin
  // We assume our caller has passed correct Count
  SetLength(Result, Count);
  Count := 0;
  for x in Self do
  begin
    Result[Count] := x;
    Inc(Count);
  end;
end;

Here is the stack track for that part:

Vcl.Themes.{System.Generics.Collections}TEnumerable<System.string>.ToArrayImpl(1)
:01201989 {System.Generics.Collections}TDictionary<System.string,System.Tether.Manager.TTetheringAdapterClass>.TKeyCollection.ToArray + $15
:011fdcd3 TTetheringManager.RegisterProfile + $1B
uMain.TfrmMain.FormCreate($82F69A0)
Vcl.Forms.TCustomForm.DoCreate
Vcl.Forms.TCustomForm.AfterConstruction
:00686b37 TCustomForm.AfterConstruction + $17
Vcl.Forms.TCustomForm.Create(???)
Vcl.Forms.TApplication.CreateForm(???,(no value))
JAM.JAM
:76d07c04 KERNEL32.BaseThreadInitThunk + 0x24
:776eab8f ntdll.RtlInitializeExceptionChain + 0x8f
:776eab5a ntdll.RtlInitializeExceptionChain + 0x5a

当我走出 ToArrayImpl 方法时,它给出了异常......

知道如何解决这个问题吗?

delphi rtti delphi-xe6 tethering
1个回答
-1
投票

请注意,请不要使用 Delphi Berlim 10.1 Update 2 没有来源,退休状态和功能。

{$WEAKLINKRTTI ON} {$RTTI 显式方法([]) 属性([]) 字段([])}

© www.soinside.com 2019 - 2024. All rights reserved.