[GH-ISSUE #221] Passing C# List<> from ListModel to another C# class through QML_JS throws exception under .NetFramework #139

Open
opened 2026-05-05 11:06:37 -06:00 by gitea-mirror · 0 comments
Owner

Originally created by @FieryRider on GitHub (Aug 26, 2020).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/221

UPDATE Almost a year later I reran my test project with new Visual studio and the error has more info now (updated StackTrace) (I also updated QML.NET but even with 0.11.0 the exception has more info)

Summary: Passing a List<string> (or any other type) that lives inside C# class that is a model for a QML ListView to a function in another C# class throws 'System.security.VerificationException' in Qml.Net.dll.
Qml.Net Version: 0.11.0

Basically I have a C# class that is a model (with id: simpleList) for a ListView that has List<string> strings inside. I am trying to pass the List<string> strings to a function (TestFunction(List<string> strings)) in another C# class called MainController (that has id: mainController inside QML) through QML like this: mainController.testFunction(simpleList.strings). This throws throws 'System.security.VerificationException' in Qml.Net.dll under .NetFramework.

StackTrace:

Unhandled Exception: System.Security.VerificationException: Operation could destabilize the runtime.
   at method(NetReference , NetVariantList , NetVariant , Task& )
   at Qml.Net.Internal.DefaultCallbacks.InvokeMethod(IntPtr m, IntPtr t, IntPtr p, IntPtr r)
   at QmlNetTest.Program.Main(String[] args) in D:\@UserFolder@\Documents\code\C#\TestRepo1\QmlNetTest\Program.cs:line 21
Object 0x18566b49b30 destroyed while one of its QML signal handlers is in progress.
Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
This behavior is NOT supported!
file:///D:/@UserFolder@/Documents/code/C%23/TestRepo1/QmlNetTest/bin/x64/Release/Main.qml:18: function() { [native code] }

It works fine under .NetCore.

Here is a repro repo.

Originally created by @FieryRider on GitHub (Aug 26, 2020). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/221 **UPDATE** Almost a year later I reran my test project with new Visual studio and the error has more info now (**updated StackTrace**) _(I also updated QML.NET but even with `0.11.0` the exception has more info)_ **Summary**: Passing a `List<string>` (or any other type) that lives inside `C# class` that is a `model` for a QML `ListView` to a function in another `C# class` throws `'System.security.VerificationException' in Qml.Net.dll`. **Qml.Net Version**: 0.11.0 Basically I have a `C# class` that is a `model` (with `id: simpleList`) for a `ListView` that has `List<string> strings` inside. I am trying to pass the `List<string> strings` to a function (`TestFunction(List<string> strings)`) in another `C# class` called `MainController` (that has `id: mainController` inside QML) through QML like this: `mainController.testFunction(simpleList.strings)`. This throws throws `'System.security.VerificationException' in Qml.Net.dll` under **`.NetFramework`**. **StackTrace**: ``` Unhandled Exception: System.Security.VerificationException: Operation could destabilize the runtime. at method(NetReference , NetVariantList , NetVariant , Task& ) at Qml.Net.Internal.DefaultCallbacks.InvokeMethod(IntPtr m, IntPtr t, IntPtr p, IntPtr r) at QmlNetTest.Program.Main(String[] args) in D:\@UserFolder@\Documents\code\C#\TestRepo1\QmlNetTest\Program.cs:line 21 Object 0x18566b49b30 destroyed while one of its QML signal handlers is in progress. Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop. This behavior is NOT supported! file:///D:/@UserFolder@/Documents/code/C%23/TestRepo1/QmlNetTest/bin/x64/Release/Main.qml:18: function() { [native code] } ``` **It works fine under `.NetCore`.** [Here](https://github.com/FieryRider/TestRepo1) is a repro repo.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#139
No description provided.