{"id":9956,"date":"2024-12-17T22:36:24","date_gmt":"2024-12-17T21:36:24","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=9956"},"modified":"2024-12-18T09:18:45","modified_gmt":"2024-12-18T08:18:45","slug":"windows-pe-net-openfiledialog-raises-exception-80040154","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/windows-pe-net-openfiledialog-raises-exception-80040154\/","title":{"rendered":"Windows PE: .NET OpenFileDialog raises exception 80040154"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_9956 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_9956')){$('.twoclick_social_bookmarks_post_9956').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Windows%20PE%3A%20.NET%20OpenFileDialog%20raises%20exception%2080040154\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0AI%20wrote%20an%20.NET%20C%23%20application%20where%20I%20want%20to%20use%20the%20OpenFileDialog%20class%20for%20chosing%20a%20file%20for%20some%20actions.%20This%20program%20should%20also%20run%20on%20Windows%20PE.%0D%0A%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/windows-pe-net-openfiledialog-raises-exception-80040154\\\/\",\"post_id\":9956,\"post_title_referrer_track\":\"Windows+PE%3A+.NET+OpenFileDialog+raises+exception+80040154\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>I wrote an .NET C# application where I want to use the OpenFileDialog class for chosing a file for some actions. This program should also run on Windows PE.<\/p>\n<p><!--more--><\/p>\n<p>On Windows PE when I try to open the OpenFileDialog an exception was raised: <\/p>\n<p><strong>&#8220;Retrieving the COM class factory for component with CLSID {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7} failed due to the following error: 80040154. at System.Windows.Forms.OpenFileDialog.CreateVistaDialog() at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner) at System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner) at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner) at System.Windows.Forms.CommonDialog.ShowDialog() at ScruffyDuck.AirportDesignEditor.MainForm.getOpenFileInfo(String initialDirectory, String filter)&#8221;<\/strong><\/p>\n<figure id=\"attachment_9957\" aria-describedby=\"caption-attachment-9957\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/OpenFileDialog_Exception.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/OpenFileDialog_Exception-300x143.png\" alt=\"OpenFileDialog Exception\" width=\"300\" height=\"143\" class=\"size-medium wp-image-9957\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/OpenFileDialog_Exception-300x143.png 300w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/OpenFileDialog_Exception.png 622w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-9957\" class=\"wp-caption-text\">OpenFileDialog Exception<\/figcaption><\/figure>\n<p>I started procmon to see what&#8217;s happend in background and found out that on Windows PE some DLL are not present:<\/p>\n<figure id=\"attachment_9958\" aria-describedby=\"caption-attachment-9958\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog-300x28.png\" alt=\"Procmon trace OpenFileDialog\" width=\"300\" height=\"28\" class=\"size-medium wp-image-9958\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog-300x28.png 300w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog-1024x95.png 1024w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog-768x72.png 768w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2024\/12\/Procmon_trace_OpenFileDialog.png 1396w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-9958\" class=\"wp-caption-text\">Procmon trace OpenFileDialog<\/figcaption><\/figure>\n<p>The &#8220;ShellStyle.dll&#8221; is missing. <\/p>\n<p>I&#8217;m went back to the computer where I created my the WinPE image and added also the ShellStyle.dll from this computer (Architecture and Buildnumber of WinPE and the of the Windows from where you copy ShellStyle.dll from should be the same) to the WinPE System32 Folder X:\\Windows\\System32<\/p>\n<p>Also <strong>edputil.dll<\/strong> and <strong>ExplorerFrame.dll<\/strong> are also required, otherwise the OpenFileDialog opens but the folder view is empty.<\/p>\n<p>For the ExplorerFrame.dll the class registration HKLM\\Software\\CLasses\\CLSID\\{AE054212-3535-4430-83ED-D501AA6680E6} must be created in Windows PE.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nWindows Registry Editor Version 5.00\r\n\r\n&#x5B;HKEY_LOCAL_MACHINE\\Software\\Classes\\CLSID\\{AE054212-3535-4430-83ED-D501AA6680E6}]\r\n@=&quot;Shell Name Space ListView&quot;\r\n\r\n&#x5B;HKEY_LOCAL_MACHINE\\Software\\Classes\\CLSID\\{AE054212-3535-4430-83ED-D501AA6680E6}\\InProcServer32]\r\n@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\\\r\n  00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,65,00,78,00,\\\r\n  70,00,6c,00,6f,00,72,00,65,00,72,00,66,00,72,00,61,00,6d,00,65,00,2e,00,64,\\\r\n  00,6c,00,6c,00,00,00\r\n&quot;ThreadingModel&quot;=&quot;Apartment&quot;\r\n<\/pre>\n<p>During the creation of the Windows PE load the PE&#8217;s Software registry and add the missing key.<\/p>\n<p>After adding the DLL&#8217;s to the system32 folder the application works as expected \ud83d\ude42<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, I wrote an .NET C# application where I want to use the OpenFileDialog class for chosing a file for some actions. This program should also run on Windows PE.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[150,2,4],"tags":[],"class_list":["post-9956","post","type-post","status-publish","format-standard","hentry","category-c","category-windows","category-windowsscripts"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/9956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=9956"}],"version-history":[{"count":10,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/9956\/revisions"}],"predecessor-version":[{"id":9968,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/9956\/revisions\/9968"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=9956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=9956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=9956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}