Using MWArray in .NET 6 Application throws exception

6 Ansichten (letzte 30 Tage)
Philipp Gun
Philipp Gun am 18 Nov. 2022
In my .NET 6 WPF Application i try to reference the MWArray.dll provided by Mathworks to access a dll i build with the MATLAB2022b Library compiler.
Path of MWArray.dll: C:\Program Files\MATLAB\R2022b\toolbox\dotnetbuilder\bin\win64\netstandard2.0\MWArray.dll
When trying to instanciate my dll:
this.matLibrary = new MatLabInterface.MatlabLibrary();
the application crashes with the following error message:
System.TypeInitializationException: The type initializer for 'MatLabInterface.MatlabLibrary' threw an exception.
---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception.
---> System.TypeLoadException: Could not load type 'System.Web.UI.WebResourceAttribute' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.ModuleHandle.ResolveType(QCallModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType)
at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
--- End of inner exception stack trace ---
at MatLabInterface.MatlabLibrary..cctor()
--- End of inner exception stack trace ---
at MatLabInterface.MatlabLibrary..ctor()
Has anyone ever experienced the same issue?
As a note: This Dll worked with my Framework 4.7.0 Version of the same program. I´m currently trying to migrate to .NET6
I already tried the v4.0 MWArray too.
What I also tried or did was to enable the Flag in the MatLab Library compiler to compile the DLL for .NET 5.0 MATLAB Library Compiler Options

Antworten (0)

Kategorien

Mehr zu MATLAB Compiler SDK finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by