C# unable to catch all exceptions -


i'm writing c# application (in linux mono shouldn't matter) , programming duplicati dlls. want program never crashes tried catch every exception. problem exception thrown , can't catch it. maybe thread?!?

sidenote: testing purposes intentionally tried backup location don't have permission. if give permission, no error.

the code looks following:

try {     interface = new interface(backend, options);     result = i.backup(folders.toarray()); } catch (exception e) {     //write log.     //here no throw; !! } 

i following stack trace:

error : system.exception: failed retrieve file listing: access path "/home/pi/test" denied. ---> system.unauthorizedaccessexception: access path "/home/pi/test" denied.   @ system.io.directory.getfilesystementries (system.string path, system.string searchpattern, fileattributes mask, fileattributes attrs) [0x00000] in <filename unknown>:0   @ system.io.directory.getfiles (system.string path, system.string searchpattern) [0x00000] in <filename unknown>:0   @ system.io.directory.getfiles (system.string path) [0x00000] in <filename unknown>:0   @ duplicati.library.backend.file.list () [0x00000] in <filename unknown>:0   @ duplicati.library.main.backendwrapper.listinternal () [0x00000] in <filename unknown>:0   --- end of inner exception stack trace ---   @ duplicati.library.main.backendwrapper.listinternal () [0x00000] in <filename unknown>:0   @ (wrapper managed-to-native) system.reflection.monomethod:internalinvoke (system.reflection.monomethod,object,object[],system.exception&)   @ system.reflection.monomethod.invoke (system.object obj, bindingflags invokeattr, system.reflection.binder binder, system.object[] parameters, system.globalization.cultureinfo culture) [0x00000] in <filename unknown>:0 

why unable catch exceptions? doing wrong?

error : system.exception: failed retrieve file listing: access path... 

well, managed exception , should able catch it, period. duplicati using interop native libraries, , failure in call call stack beings, unwinding , propagating through managed call stack.

i wrote quick duplicati example , catches exceptions...

no exception:

mono hellodup.exe "/tmp" file: local folder or drive 

exception caught:

ls /home/private/privateinfo ls: : permission denied mono hellodup.exe "/home/private/privateinfo" exception: access path "/home/private/privateinfo" denied.: type:system.unauthorizedaccessexception 

exception caught:

mono hellodup.exe "/foobar" exception: folder /foobar not exist: type:duplicati.library.interface.foldermissingexception 

exception caught:

ls -l /noperms/private.txt --w-------  1 root  wheel  0 jun 25 14:16 /noperms/private.txt mono hellodup.exe "/noperms/private.txt" exception: folder /noperms/private.txt not exist: type:duplicati.library.interface.foldermissingexception 

code example:

try {     var file = new duplicati.library.backend.file(args[0], options);     file.createfolder();     console.writeline ("file: {0}", file.displayname); } catch (exception e) {     console.writeline ("exception: {0}: type:{1}", e.message, e.gettype()); } 

next steps:

i check versions of mono , duplicati using... if base system install of mono, behind times. used xbuild compile duplicati i'm using head of github master branch.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -