在 C++ Builder 10 中加载 DLL 时变体或安全数组被锁定
Variant or safe array is locked When Load DLL in C++ Builder 10
我已将 C++ 项目 6 升级到 C++ 构建器 10。
当我使用 LoadLibrary 加载 DLL 时,抛出该异常。
HINSTANCE hInst;
hInst = LoadLibrary( "MyLibrary.dll" );
Project XXXX.exe raised exception class EOutOfResources with message
'Variant or safe array is locked'.
我没看懂那个"Variant or safe array is locked"表达式。
我试过在新的空 application.DLL 中加载 DLL loading.There 没问题。
但无法在现有项目中加载 DLL。
如何确定问题的根源?
看看这是否有帮助:
Migrating legacy C++ Builder Apps to C++ Builder 10 Seattle
特别是这两句话:
Any libraries that were built with an older version of C++ Builder
will need to be recompiled in order to be used by a C++ Builder 10
Seattle project.
和
Don't let C++ Builder 10 Seattle convert your older Builder project.
Copy your files into a new folder, create a new project and add your
source files to it
问题原因;
我用 notepad++ 比较了两个 .cbproj 文件
我用 C++ Builder 10 创建了 DLL
<PropertyGroup>
<ProjectGuid>{E3FB4C71-C382-46EC-A17D-5C25890309CD}</ProjectGuid>
<ProjectVersion>18.0</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Library</AppType>
</PropertyGroup>
我将 DLL C++ Builder 6 升级到 10
<PropertyGroup>
<ProjectGuid>{923C6CCC-2F12-4C36-B9B1-C765AE96A7A2}</ProjectGuid>
<ProjectType>CppDynamicLibrary</ProjectType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<FrameworkType>None</FrameworkType>
<ProjectVersion>18.0</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Library</AppType>
</PropertyGroup>
区别在于FrameworkType。
我已将 None 替换为 VCL。
DLL 已加载。
我已将 C++ 项目 6 升级到 C++ 构建器 10。
当我使用 LoadLibrary 加载 DLL 时,抛出该异常。
HINSTANCE hInst;
hInst = LoadLibrary( "MyLibrary.dll" );
Project XXXX.exe raised exception class EOutOfResources with message 'Variant or safe array is locked'.
我没看懂那个"Variant or safe array is locked"表达式。
我试过在新的空 application.DLL 中加载 DLL loading.There 没问题。
但无法在现有项目中加载 DLL。
如何确定问题的根源?
看看这是否有帮助:
Migrating legacy C++ Builder Apps to C++ Builder 10 Seattle
特别是这两句话:
Any libraries that were built with an older version of C++ Builder will need to be recompiled in order to be used by a C++ Builder 10 Seattle project.
和
Don't let C++ Builder 10 Seattle convert your older Builder project. Copy your files into a new folder, create a new project and add your source files to it
问题原因;
我用 notepad++ 比较了两个 .cbproj 文件
我用 C++ Builder 10 创建了 DLL
<PropertyGroup>
<ProjectGuid>{E3FB4C71-C382-46EC-A17D-5C25890309CD}</ProjectGuid>
<ProjectVersion>18.0</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Library</AppType>
</PropertyGroup>
我将 DLL C++ Builder 6 升级到 10
<PropertyGroup>
<ProjectGuid>{923C6CCC-2F12-4C36-B9B1-C765AE96A7A2}</ProjectGuid>
<ProjectType>CppDynamicLibrary</ProjectType>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<FrameworkType>None</FrameworkType>
<ProjectVersion>18.0</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Library</AppType>
</PropertyGroup>
区别在于FrameworkType。
我已将 None 替换为 VCL。
DLL 已加载。