What causes an "Unable to load DLL dependency: KERNEL32.dll.GetFileSizeEx" error on the target screen when attempting to load an SLRT application in R2018b or prior?
21 views (last 30 days)
Show older comments
MathWorks Support Team
on 31 Oct 2018
Edited: MathWorks Support Team
on 22 Oct 2025 at 22:16
NOTE: This article is only relevant for Simulink Real-Time R2018b or earlier and does not apply to newer versions.
When building a Simulink model for Simulink Real-Time (SLRT) with the latest version of Microsoft Visual Studio C++ 2017, the following error is shown on the target screen (or obtained using the command "tg.viewTargetScreen") when attempting to load the application.
ERROR: Unable to load DLL dependency: KERNEL32.dll.GetFileSizeEx
Loading C:\private\xpcosc.dlm failed with error 127
Error: Could not load model C:\private\xpcosc: 127
When running the command "slrttest" the error might appear as:
>> slrttest
### Simulink Real-Time Test Suite ### Host-Target interface is: TcpIp
### Test 1, Ping target computer 'TargetPC1' using system ping: ... OK
### Test 2, Ping target computer 'TargetPC1' using SLRTPINGTARGET: ... OK
### Test 3, Software reboot the target computer 'TargetPC1': ...... OK
### Test 4, Build and download a Simulink Real-Time application using model slrttestmdl to target computer 'TargetPC1': ...Warning: Error occurred while executing the listener callback for event Loaded defined for class
MathWorks.xPCTarget.FrameWork.xPCTargetPC:
Error using SimulinkRealTime.target/XCPLoadedCB
Enter a valid application name
> In SimulinkRealTime.target/loa
In slrttest (line 212) OK
### Test 5, Check host-target command communications with 'TargetPC1': ... FAILED
When building a model for SLRT, you may see the following warnings and errors:
### Download model onto target: TargetPC1Warning: Error occurred while executing the listener callback for event Loaded defined for class
MathWorks.xPCTarget.FrameWork.xPCTargetPC:
Error using SimulinkRealTime.target/XCPLoadedCB
Enter a valid application name
### Create SimulinkRealTime.target object tgError using coder.internal.callMakeHook
The call to slrt_make_rtw_hook, during the exit hook generated the following error:
Invalid Simulink object name: loader
The build process will terminate as a result.<...>
Caused by:
Error using dispIfVerbose (line 31)
Invalid Simulink object name: loader
Error using dispIfVerbose (line 31)
No block diagram 'loader' is loaded.
Additionally, the following warning may appear in Diagnostic Viewer:
Warning: Streaming to SDI is not available: Could not connect to XCP slave: XCP Master internal error: Connect failed
Accepted Answer
MathWorks Support Team
on 21 Oct 2025 at 0:00
Edited: MathWorks Support Team
2 minutes ago
This is a known incompatibility with newer Windows 10 SDK versions. Please refer to the following bug report for fixes and workarounds:
IMPORTANT NOTE: If you have multiple versions of Visual Studio installed on your PC, ensure that none of them include Windows SDKs version 10.0.17134.0 or newer, as MATLAB automatically uses the latest available Windows 10 SDK on your system.
For example, even if you're compiling with Visual Studio 2017 and have reinstalled it with the correct Windows 10 SDK (10.17134.0), MATLAB may still pick the newer SDK from Visual Studio 2019 or 2022, which can cause the above errors to persist.
If your setup requires multiple Visual Studio versions, and you are unable to remove Windows SDKs version 10.0.17134.0 or newer, consider using a separate PC dedicated to Simulink Real-Time with only Visual Studio 2017 and the correct SDK installed.
1 Comment
Stefanie Schwarz
on 14 May 2020
If the above does not help, please contact MathWorks Technical Support for further assistance: https://www.mathworks.com/support/contact_us.html
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!