How can I give MATLAB permission to access a library?

6 views (last 30 days)
Hi, I am trying to access methods of a NET dll using NET.addAssembly(). I can load the library and see the class name, but when I call the methods, I get the following access denied error. The dll is for a iHR320 spectrometer. I don't know hot to get MATLAB the access permission. When using visual studio to call the methods, VS asks for permission, but MATLAB doesn't ask, it just crashes. Any comments or suggestions is truly appreciated.
The error I get:
MATLAB crash file:C:\Users\icbiolab\AppData\Local\Temp\matlab_crash_dump.12296-1:
------------------------------------------------------------------------
Access violation detected at Tue Apr 12 13:33:16 2022
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled
Crash Mode : continue (default)
Current Graphics Driver: Unknown hardware
Default Encoding : windows-1252
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 4600 Version 20.19.15.4531
Host Name : DESKTOP-9NKN5UO
MATLAB Architecture : win32
MATLAB Root : C:\Program Files (x86)\MATLAB\R2015b
MATLAB Version : 8.6.0.267246 (R2015b)
OpenGL : hardware
Operating System : Microsoft Windows 10 Enterprise
Processor ID : x86 Family 6 Model 60 Stepping 3, GenuineIntel
Virtual Machine : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) Client VM mixed mode
Window System : Version 10.0 (Build 19042)
Fault Count: 1
Abnormal termination:
Access violation
Register State (from fault):
EAX = 00120596 EBX = 0e713a08
ECX = 00000000 EDX = 00000081
ESP = 00c2c738 EBP = 00c2c758
ESI = 00120596 EDI = 00000081
EIP = 0e8c783c EFL = 00210202
CS = 00000023 DS = 0000002b SS = 0000002b
ES = 0000002b FS = 00000053 GS = 0000002b
Stack Trace (from fault):
[ 0] 0x0e8c783c <unknown-module>+00000000
[ 1] 0x0e757316 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00291606 DllRegisterServer+00277185
[ 2] 0x76fd109b C:\WINDOWS\System32\USER32.dll+00266395 AddClipboardFormatListener+00000075
[ 3] 0x76fc805a C:\WINDOWS\System32\USER32.dll+00229466 GetClassLongW+00001962
[ 4] 0x76fc7c5a C:\WINDOWS\System32\USER32.dll+00228442 GetClassLongW+00000938
[ 5] 0x76fcef49 C:\WINDOWS\System32\USER32.dll+00257865 GetDC+00000137
[ 6] 0x771b4e7d C:\WINDOWS\SYSTEM32\ntdll.dll+00478845 KiUserCallbackDispatcher+00000077
[ 7] 0x76fbf857 C:\WINDOWS\System32\USER32.dll+00194647 CreateWindowExW+00000359
[ 8] 0x76fb8648 C:\WINDOWS\System32\USER32.dll+00165448 CreateWindowExA+00000056
[ 9] 0x0e7576c2 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00292546 DllRegisterServer+00278125
[ 10] 0x0e753562 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00275810 DllRegisterServer+00261389
[ 11] 0x0e752bc9 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00273353 DllRegisterServer+00258932
[ 12] 0x0e752a59 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00272985 DllRegisterServer+00258564
[ 13] 0x0e752239 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00270905 DllRegisterServer+00256484
[ 14] 0x0e752443 C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Monos\JYMono\JYMono.dll+00271427 DllRegisterServer+00257006
[ 15] 0x735444f6 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+01590518 ClrCreateManagedInstance+00048422
[ 16] 0x735445f6 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+01590774 ClrCreateManagedInstance+00048678
[ 17] 0x7354469f C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+01590943 ClrCreateManagedInstance+00048847
[ 18] 0x73544751 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+01591121 ClrCreateManagedInstance+00049025
[ 19] 0x733e2e66 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+00142950 LogHelp_NoGuiOnAssert+00029606
[ 20] 0x721d71a7 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\45cedc1e1f7c1e207ea61b42066b2e96\mscorlib.ni.dll+04813223
[ 21] 0x721d6ece C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\45cedc1e1f7c1e207ea61b42066b2e96\mscorlib.ni.dll+04812494
[ 22] 0x733cf178 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+00061816
[ 23] 0x734a09af C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+00919983 CoUninitializeEE+00127871
[ 24] 0x734a0aab C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+00920235 CoUninitializeEE+00128123
[ 25] 0x73874bc8 C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll+04934600 CreateHistoryReader+01544312
[ 26] 0x72165ce9 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\45cedc1e1f7c1e207ea61b42066b2e96\mscorlib.ni.dll+04349161
[ 27] 0x72166bc4 C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\45cedc1e1f7c1e207ea61b42066b2e96\mscorlib.ni.dll+04352964
[ 28] 0x397562ee <unknown-module>+00000000
[ 29] 0x39780d23 <unknown-module>+00000000
[ 30] 0x0c11eaaa C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00060074
[ 31] 0x0c120116 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00065814
[ 32] 0x0c121c92 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00072850
[ 33] 0x0c120385 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00066437
[ 34] 0x0c1bf777 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00718711 QueryMLFcnTable_mcos_impl+00365015
[ 35] 0x0c1bf828 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00718888 QueryMLFcnTable_mcos_impl+00365192
[ 36] 0x0c12245c C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00074844
[ 37] 0x0c153280 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00275072
[ 38] 0x07c39f69 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_dispatcher.dll+00040809 Mfh_MATLAB_fn::dispatch_fh+00000585
[ 39] 0x0c15660f C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcos_impl.dll+00288271
[ 40] 0x07c39ca5 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_dispatcher.dll+00040101 Mfunction_handle::dispatch+00000917
[ 41] 0x089c8da7 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06852007 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00468519
[ 42] 0x089c2193 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06824339 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00440851
[ 43] 0x089c2300 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06824704 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00441216
[ 44] 0x089e3092 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06959250 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00575762
[ 45] 0x08a6b08c C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07516300 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01132812
[ 46] 0x08a6b867 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07518311 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01134823
[ 47] 0x08a73225 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07549477 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01165989
[ 48] 0x08a73053 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07549011 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01165523
[ 49] 0x08a765d9 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07562713 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01179225
[ 50] 0x08aca8bc C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07907516 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01524028
[ 51] 0x086e619c C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03826076
[ 52] 0x086d3bd6 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03750870
[ 53] 0x086db025 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03780645
[ 54] 0x0889b87a C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05617786
[ 55] 0x089b2cac C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06761644 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00378156
[ 56] 0x089b289d C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06760605 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00377117
[ 57] 0x089b6132 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06775090 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00391602
[ 58] 0x07c398b3 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_dispatcher.dll+00039091 Mfh_file::dispatch_fh_impl+00001059
[ 59] 0x07c3948b C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_dispatcher.dll+00038027 Mfh_file::dispatch_fh+00000027
[ 60] 0x07c39ca5 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_dispatcher.dll+00040101 Mfunction_handle::dispatch+00000917
[ 61] 0x089bc4d1 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06800593 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00417105
[ 62] 0x089c7502 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+06845698 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+00462210
[ 63] 0x08b116b8 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+08197816 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01814328
[ 64] 0x08abe8dc C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+07858396 boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,MathWorks::lxe::MatlabIrTree>::save_object_ptr+01474908
[ 65] 0x086e619c C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03826076
[ 66] 0x086d3bd6 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03750870
[ 67] 0x086db025 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+03780645
[ 68] 0x0889b87a C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05617786
[ 69] 0x0885b696 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05355158
[ 70] 0x0885c2f5 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05358325
[ 71] 0x0885c228 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05358120
[ 72] 0x088e3c45 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05913669 MathWorks::lxe::registerMcrContexts+00183845
[ 73] 0x088e698e C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05925262 MathWorks::lxe::registerMcrContexts+00195438
[ 74] 0x088e602f C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05922863 MathWorks::lxe::registerMcrContexts+00193039
[ 75] 0x088e62ee C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_lxe.dll+05923566 MathWorks::lxe::registerMcrContexts+00193742
[ 76] 0x07d6db4d C:\Program Files (x86)\MATLAB\R2015b\bin\win32\m_interpreter.dll+00580429 inEvalCmdWithLocalReturn+00000029
[ 77] 0x7ba91c23 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwbridge.dll+00072739 mnGetPrompt+00003651
[ 78] 0x7ba92712 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwbridge.dll+00075538 mnParser+00001042
[ 79] 0x07bc6373 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00353139 mcrInstance::mnParser_on_interpreter_thread+00000051
[ 80] 0x07b9b275 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00176757 mcr::runtime::setInterpreterThreadToCurrent+00017765
[ 81] 0x07b9b2e6 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00176870 mcr::runtime::setInterpreterThreadToCurrent+00017878
[ 82] 0x07b9cabf C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00182975 mcr::runtime::setInterpreterThreadToCurrent+00023983
[ 83] 0x07b9ca12 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00182802 mcr::runtime::setInterpreterThreadToCurrent+00023810
[ 84] 0x07b9ba66 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00178790 mcr::runtime::setInterpreterThreadToCurrent+00019798
[ 85] 0x7b72669b C:\Program Files (x86)\MATLAB\R2015b\bin\win32\uiw.dll+00485019 UIW_AttachThreadInput+00000843
[ 86] 0x7b7260d7 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\uiw.dll+00483543 wsd_to_MSW+00004023
[ 87] 0x7b72618b C:\Program Files (x86)\MATLAB\R2015b\bin\win32\uiw.dll+00483723 wsd_to_MSW+00004203
[ 88] 0x76fb5579 C:\WINDOWS\System32\USER32.dll+00152953 TranslateAcceleratorW+00000681
[ 89] 0x76fcb5d9 C:\WINDOWS\System32\USER32.dll+00243161 Ordinal2712+00000457
[ 90] 0x76fcb525 C:\WINDOWS\System32\USER32.dll+00242981 Ordinal2712+00000277
[ 91] 0x771b4e7d C:\WINDOWS\SYSTEM32\ntdll.dll+00478845 KiUserCallbackDispatcher+00000077
[ 92] 0x76fb020d C:\WINDOWS\System32\USER32.dll+00131597 PeekMessageA+00000413
[ 93] 0x7b6d918a C:\Program Files (x86)\MATLAB\R2015b\bin\win32\uiw.dll+00168330 UIW_ShowMenuItem+00004986
[ 94] 0x7b726ff4 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\uiw.dll+00487412 UIW_SuspendAttachThreadInput+00000708
[ 95] 0x04562434 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01451060 services::system_events::PpeDispatchHook::dispatchOne+00029092
[ 96] 0x0456ed56 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01502550 sysq::addProcessPendingEventsUnitTestHook+00007942
[ 97] 0x045604be C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01443006 services::system_events::PpeDispatchHook::dispatchOne+00021038
[ 98] 0x0456ee01 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01502721 sysq::addProcessPendingEventsUnitTestHook+00008113
[ 99] 0x045707a9 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01509289 sysq::getCondition+00003833
[100] 0x04571f2b C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01515307 svWS_ProcessPendingEvents+00000139
[101] 0x04571e90 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\libmwservices.dll+01515152 svWS_ProcessPendingEvents+00000016
[102] 0x07b9c111 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00180497 mcr::runtime::setInterpreterThreadToCurrent+00021505
[103] 0x07b9cc8d C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00183437 mcr::runtime::setInterpreterThreadToCurrent+00024445
[104] 0x07b9516f C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00151919 mcr_process_events+00006879
[105] 0x07b96b93 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mcr.dll+00158611 mcr_process_events+00013571
[106] 0x07a52e3d C:\Program Files (x86)\MATLAB\R2015b\bin\win32\MVMLocal.dll+00208445 mvm_server::inproc::LocalFactory::terminate+00079565
[107] 0x7b421681 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mvm.dll+01054337 mvm::detail::initLocalMvmHack+00000433
[108] 0x7b42084b C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mvm.dll+01050699 mvm::detail::RequestMvmMessage::toString+00007787
[109] 0x7b421cad C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mvm.dll+01055917 mvm::detail::SessionImpl::privateSession+00000285
[110] 0x7b421e60 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\mvm.dll+01056352 mvm::detail::SessionImpl::privateSession+00000720
[111] 0x00405e2a C:\Program Files (x86)\MATLAB\R2015b\bin\win32\MATLAB.exe+00024106
[112] 0x00407747 C:\Program Files (x86)\MATLAB\R2015b\bin\win32\MATLAB.exe+00030535
[113] 0x7502fa29 C:\WINDOWS\System32\KERNEL32.DLL+00129577 BaseThreadInitThunk+00000025
[114] 0x771a7a7e C:\WINDOWS\SYSTEM32\ntdll.dll+00424574 RtlGetAppContainerNamedObjectPath+00000286
[115] 0x771a7a4e C:\WINDOWS\SYSTEM32\ntdll.dll+00424526 RtlGetAppContainerNamedObjectPath+00000238
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.

Answers (1)

Yash
Yash on 27 Dec 2023
Hi Fahimeh,
I understand that you're encountering a permissions issue when trying to access methods from a .NET DLL within MATLAB. This can be a complex issue because it involves the interaction between MATLAB, the .NET framework, and the operating system's security settings.
If the DLL works with administrative privileges in Visual Studio, it's likely a permissions issue that can be resolved by running MATLAB as an administrator or adjusting the DLL and its dependencies' security settings. I am assuming that you are on a Windows device according to the screenshot that you have shared in the comments.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
1. Run MATLAB as Administrator: This is the most straightforward step. If you are not opening MATLAB as administrator, MATLAB won't have access to every folder due to the operating system's security. Follow the below mentioned steps to open MATLAB as administrator.
  • Close MATLAB if it's open.
  • Right-click the MATLAB shortcut and select "Run as administrator".
  • Try loading the DLL and accessing its methods again.
2. Check DLL Permissions:
  • Ensure that the DLL file and any dependencies have the appropriate permissions set. You can do this by right-clicking the DLL file in the File Explorer, selecting "Properties", and then navigating to the "Security" tab.
Hope this helps in resolving the issue.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!