MATLAB: What causes an “Unable to load DLL dependency” error on the target screen when attempting to load an SLRT application

getfilesizeexkernel32kernel32.dll

When building a Simulink model for Simulink Real-Time 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.
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/load In slrttest (line 212) OK
### Test 5, Check host-target command communications with 'TargetPC1': ... FAILED
Alternatively, the following warning may appear in Step 4:
Warning: Streaming to SDI is not available: Could not connect to XCP slave: XCP Master internal error: Connect failed

Best Answer

Please refer to the following bug report for fixes and workarounds: