"The specified key is not present in this container" error when attempting to build a Simulink model with C Caller function blocks

68 visualizaciones (últimos 30 días)
Hi,
I have inserted some C Caller function blocks in a model which call functions from a dll located within a C:\Program Files directory on Windows.
Simulink didn't seem to like linking to the dll in its original installation location so I copied it and the matching .lib file to the Simulink project folder.
When I try to build the model, Simulink reports "The specified key is not present in this container", but it is not clear what it refers to. I suspect it is something to do with the configuration settings which I have attached here. If I generate a new configuration file without reference to the dll and add a sine wave block plus scope (C caller blocks are commented out), it builds.
Any ideas on what is causing the issue would be much appreciated.

Respuestas (1)

Mark McBroom
Mark McBroom el 8 de Mayo de 2021
The configuration should only refer to the .lib file. This is the only file needed for linking. Use double quotes around the .lib path name to avoid having to copy the .lib file to the same directory as the model.
  7 comentarios
HM
HM el 13 de Mayo de 2021
I've double checked to ensure that the dll is not being referenced in Custom Code section:
The include directory is also set to the 'inc' folder of the SDK shown above.
I have removed any sub-folders in the slprj file and also ensured that the location of the header and dll are not on the MATLAB path - I ran the following as a check and confirmed that the dll could not be found:
which ps2000.dll
Is there anything else that I can check?
HM
HM el 15 de Jun. de 2021
I've run some further tests:
  1. I opened MATLAB & Simulink as an Administrator - if I open just the model and library files, I am able to use the C Caller blocks. If I open the project, and attempt to run the model, that also works. I realised that the dll was present in some of the build folders but I deleted it and repeated the tests and that is fine.
  2. If I start MATLAB & Simulink as normal, I can open the model and library file, and run the model. However, I get the error if I try to run the model having opened the project.
Could this be down to something in the project settings related to compiling the model/code generation? I'm not developing the model for code generation purposes.
Many thanks,

Iniciar sesión para comentar.

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by