Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.AccessViolationException exception in C# and shell32.dll
    primarykey
    data
    text
    <p>i write a snippet code that deletes a specified directory in SHFileOperation method. </p> <p>The SHFileOperation class from a <a href="http://www.pinvoke.net/default.aspx/shell32.shfileoperation" rel="nofollow">pinvoke.net</a></p> <p>the flowing is my test code:</p> <pre><code> var interop = new InteropSHFileOperation(); interop.wFunc = InteropSHFileOperation.FO_Func.FO_DELETE; interop.pFrom = path; interop.fFlags.FOF_SILENT = true; interop.fFlags.FOF_NOERRORUI = true; interop.fFlags.FOF_NOCONFIRMATION = true; return interop.Execute(); </code></pre> <p>the above code can worked in my computer(win7,32-bit,.net 4.0),</p> <p>but when running above code to my other computer(win 2008,64-bit,.net 4.0),i get the flowing error(from windows event viewer):</p> <pre><code>Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at Shopbots.IO.InteropSHFileOperation.SHFileOperation(SHFILEOPSTRUCT ByRef) at Shopbots.IO.InteropSHFileOperation.SHFileOperation(SHFILEOPSTRUCT ByRef) at Shopbots.IO.InteropSHFileOperation.Execute() </code></pre> <p>and from windows exceton dialog</p> <pre><code>event name : APPCRASH Fault Module Name: shell32.dll Fault Module Version: 6.0.6002.18646 Fault Module Timestamp: 4fd23d65 Exception Code: c0000005 </code></pre> <p>[update 2]</p> <p>according "<strong>Don't declare a value for the Pack size. If you omit it, the correct value is used when marshaling and a single SHFILEOPSTRUCT can be used for both 32-bit and 64-bit operation.</strong>" from a other article:<a href="http://www.pinvoke.net/default.aspx/Structures/SHFILEOPSTRUCT.html" rel="nofollow">http://www.pinvoke.net/default.aspx/Structures/SHFILEOPSTRUCT.html</a>:</p> <p>change a SHFILEOPSTRUCT declare that work 32-bit and 64-bit windows operator system(because the InteropSHFileOperation class from pinvoke site that declare a SHFILEOPSTRUCT structure for 32-bit operator system)</p> <pre><code>[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct SHFILEOPSTRUCT { .... } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload