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 VCL\ExpressCore Library\Sources\dxCore.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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值