{"id":11533,"date":"2011-02-10T07:00:00","date_gmt":"2011-02-10T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/02\/10\/psychic-debugging-because-of-course-when-something-doesnt-work-its-because-the-program-was-sabotaged-from-above\/"},"modified":"2011-02-10T07:00:00","modified_gmt":"2011-02-10T07:00:00","slug":"psychic-debugging-because-of-course-when-something-doesnt-work-its-because-the-program-was-sabotaged-from-above","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110210-00\/?p=11533","title":{"rendered":"Psychic debugging: Because of course when something doesn&#039;t work, it&#039;s because the program was sabotaged from above"},"content":{"rendered":"<p>\nWhen something stops working, you begin developing theories\nfor why it doesn&#8217;t work,\nand normally, you start with simple theories that involve\nthings close to you, and only after you exhaust those\npossibilities do you expand your scope.\nTypically, you don&#8217;t consider that there is\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2009\/10\/05\/9903476.aspx#9903930\">\na global conspiracy against you<\/a>,\nor at least that&#8217;s not usually your first theory.\n<\/p>\n<blockquote CLASS=\"q\">\n<p>\nI&#8217;m trying to use the XYZ.DLL that comes with your product.\nI have successfully registered this DLL (as specified in the\ndocumentation) by performing a\n<code>regsvr32 C:\\path\\to\\XYZ.DLL<\/code>.\n<\/p>\n<p>\nAccording to the documentation, I should now be able to create\na <code>Xyz.Xyz&shy;Widgetizer<\/code> object,\nbut when I try to do so from C#, I get the exception\n<\/p>\n<pre>\nRetrieving the COM class factory for component with CLSID\n{...} failed due to the following error: 80040154.\n<\/pre>\n<p>\nI tried using the Visual Basic code sample which comes with\nthe documentation, which contains only two lines:\n<\/p>\n<pre>\nDim oXyzWidgetizer\nSet oXyzWidgetizer = WScript.CreateObject(\"Xyz.XyzWidgetizer\")\n<\/pre>\n<p>\nHowever, it still fails with the following error:\n<\/p>\n<pre>\nMicrosoft (R) Windows Script Host Version 5.7\nCopyright (C) Microsoft Corporation. All rights reserved.\nC:\\test.vbs(2, 1) WScript.CreateObject: Could not create object\n                  named \"Xyz.XyzWidgetizer\".\n<\/pre>\n<p>\nHas support for the XyzWidgetizer been silently dropped?\n<\/p>\n<\/blockquote>\n<p>\nLet&#8217;s look at the error message more closely.\nError 80040154 is <code>REGDB_E_CLASSNOTREG<\/code>:\nThe class is not registered.\nTherefore, whatever <code>regsvr32<\/code> did,\nit didn&#8217;t register the class.\n<\/p>\n<blockquote CLASS=\"q\"><p>\nMy psychic powers tell me that you registered the 32-bit version of\nXYZ.DLL on a 64-bit machine.\n<\/p><\/blockquote>\n<p>\nRegistering the 32-bit DLL records the entries into the 32-bit registry\n(because\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2008\/12\/22\/9244582.aspx\">\n32-bit programs run in an emulator<\/a>),\nand the 32-bit registry\nis not consulted when you try to create a COM object\nfrom a 64-bit application.\nLetting 64-bit applications see the registration for 32-bit DLLs\ndoesn&#8217;t actually accomplish anything because\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2008\/10\/20\/9006720.aspx\">\nyou cannot load a 32-bit DLL into a 64-bit process and vice\nversa<\/a>&mdash;even if a 64-bit process can figure out what DLL it wants,\nit won&#8217;t able to load it.\n<\/p>\n<p>\nIt so happens that my psychic powers were correct.\nHow did I know that the person asking the question was running\nthe 32-bit version of XYZ on a 64-bit version of Windows?\nI didn&#8217;t, but it was the simplest theory that fit the (extremely\nlimited) data.\nAnd it didn&#8217;t involve a global conspiracy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When something stops working, you begin developing theories for why it doesn&#8217;t work, and normally, you start with simple theories that involve things close to you, and only after you exhaust those possibilities do you expand your scope. Typically, you don&#8217;t consider that there is a global conspiracy against you, or at least that&#8217;s not [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-11533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>When something stops working, you begin developing theories for why it doesn&#8217;t work, and normally, you start with simple theories that involve things close to you, and only after you exhaust those possibilities do you expand your scope. Typically, you don&#8217;t consider that there is a global conspiracy against you, or at least that&#8217;s not [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=11533"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11533\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=11533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=11533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=11533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}