zoukankan      html  css  js  c++  java
  • dev16 cxgrid 在DLL里报0地址错

    dev16 cxgrid 在DLL里Form里使用,报0地址错,在EXE里正常。c++builder 的DLL报错,delphi也报错。

    First chance exception at $09CE9B44. Exception class $C0000005 with message 'access violation at 0x09ce9b44: read of address 0x00000000'.

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    self.cxGrid1DBTableView1.CreateColumn;
    end;

    最终指向了 cxGridCustomTableView.pas

    function TcxCustomGridTableView.CreateItem: TcxCustomGridTableItem;
    begin
      Result := GetItemClass.Create(Owner);
      AddItem(Result);//error
    end;

    function TcxCustomGridTableItem.CanFilter(AVisually: Boolean): Boolean;
    begin
      Result :=
        (esoFiltering in GetProperties.GetSupportedOperations) and FOptions.Filtering and
        (not AVisually or GridView.OptionsCustomize.ItemFiltering and FOptions.FilteringPopup);
    end;

    DevExpress VCLExpressCore LibrarySourcesdxCore.pas  
     //在这里看到dll的初始化和exe是分开的。exe直接调用,dll在InitializeList里。InitializeList是不是需要手动调用?
     procedure TdxUnitsLoader.AddUnit(const AInitializeProc, AFinalizeProc: Pointer);
    var
      AProc: TdxProc;
    begin
      if AInitializeProc <> nil then
      begin
        AProc := AInitializeProc;
        if not dxIsDLL then
        begin
          IsInitialized := True;
          AProc;
        end
        else
          InitializeList.Add(AInitializeProc);
      end;
      if AFinalizeProc <> nil then
        FinalizeList.Add(AFinalizeProc);
    end;

    最后发现dxCore.pas文件里有2个函数,就是专门初始化的,在DLL里init和退出时finalize。

    procedure dxInitialize; stdcall;
    procedure dxFinalize; stdcall;

    The dxInitialize & dxFinalize procedure must be used if you develop your project with DLLs.

    But if you compile your DLL with active runtime packages, you don't need to call dxInitialize & dxFinalize manually.

    原来的引用dxGDIPlusAPI修改为dxCore 
    原来的方法dxGdiPlusInitialize修改为dxInitialize 
    原来的方法dxGdiPlusFinalize修改为dxFinalize

    Note that the dxInitializeGDIPlus and dxFinalizeGDIPlus functions have been moved to the dxCore unit. They were renamed to dxInitialize and dxFinalize respectively.

    参考

    http://www.cnblogs.com/jupt/p/3922935.html

    官方

    https://www.devexpress.com/Support/Center/Question/Details/Q470319/dynamic-loaded-dll-with-packages-av-s-in-dxcore

    http://bbs.2ccc.com/topic.asp?topicid=414492

    https://www.board4all.biz/threads/richeditcontrol-generates-an-error-is-this-a-bug.666000/

    https://www.devexpress.com/Support/Center/Question/Details/Q387588/delphi-xe2-and-dxinitializegdiplus-problem

  • 相关阅读:
    无题
    赌对了
    赌:
    这次是真的再见了,oi退役回忆录
    线段树(lazy标记)
    《挑战》2.1 POJ POJ 1979 Red and Black (简单的DFS)
    《挑战》2.1 POJ 2386 Lake Counting (简单的dfs)
    TC安装全系列教程
    ProblemC 剪花布条(KMP基础)
    多校+CF简单题
  • 原文地址:https://www.cnblogs.com/cb168/p/7764743.html
Copyright © 2011-2022 走看看