c# - Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE) -
using .net 4.0 / wpf application / c#
i have following piece of code in application, opens filedialog when select button clicked.
openfiledialog fdgselectfile; bool? dialogresult; try { fdgselectfile = new openfiledialog {defaultext = filedialogdefaultext, filter = filedialogfilter}; dialogresult = fdgselectfile.showdialog(); if (dialogresult.hasvalue && dialogresult.value) { selectedfilepath = fdgselectfile.filename; // stuff } } this piece of code works in other machines, not in machine. throws exception - below - when select button clicked upon.
2015-04-28 14:33:47,453 [1] error xxxx.xxxx.xxxx.viewmodels.uploadviewmodel - selectfile - system.runtime.interopservices.comexception (0x80040111): creating instance of com component clsid {dc1c5a9c-e88a-4dde-a5a1-60f82a20aef7} iclassfactory failed due following error: 80040111 classfactory cannot supply requested class (exception hresult: 0x80040111 (class_e_classnotavailable)). @ system.runtimetypehandle.createinstance(runtimetype type, boolean publiconly, boolean nocheck, boolean& canbecached, runtimemethodhandleinternal& ctor, boolean& bneedsecuritycheck) @ system.runtimetype.createinstanceslow(boolean publiconly, boolean skipcheckthis, boolean fillcache, stackcrawlmark& stackmark) @ system.runtimetype.createinstancedefaultctor(boolean publiconly, boolean skipcheckthis, boolean fillcache, stackcrawlmark& stackmark) @ system.activator.createinstance(type type, boolean nonpublic) @ system.activator.createinstance(type type) @ microsoft.win32.openfiledialog.createvistadialog() @ microsoft.win32.filedialog.runvistadialog(intptr hwndowner) @ microsoft.win32.filedialog.rundialog(intptr hwndowner) @ microsoft.win32.commondialog.showdialog() @ xxxx.xxxx.xxxx.viewmodels.uploadviewmodel.selectfile(object param) in c:\xxxx\xxxx\client\xxxx.xxxx.xxxx\viewmodels\uploadviewmodel .cs:line 176 finding out error caused comdlg32.dll microsoft.win32 namespace, inside presentationframework.dll assembly, queried registry cls id
reg query hkcr\clsid | find /i "{dc1c5a9c-e88a-4dde-a5a1-60f82a20aef7}" and here says
hkey_classes_root\clsid{dc1c5a9c-e88a-4dde-a5a1-60f82a20aef7}
i have tried following
as per this post, tried register
dll, came saying[window title] regsvr32
[content] module "comdlg32.dll" loaded entry-point dllregisterserver not found.
make sure "comdlg32.dll" valid dll or ocx file , try again.
[ok]
as per this post, tried changing
permissions, no luck
is there way can resolved apart re-imaging machine or re-installing windows?
if helps : have .net framework v3.5/ v4.0 / v4.5.1 & v4.5.2 installed in machine , presentationframework.dll available in locations inside folders
v3.5 : c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v3.5\profile\client v4.0 : c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0 v4.5 : c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.5 v4.5.1 : c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.5.1 v4.5.2 : c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.5.2
discarding possibility windows installation broken, rather insidious problem caused "visual themes" being turned off in windows 7 , above.
to reproduce can take working wpf application , modify it's compatibility settings (righ-click on .exe in windows explorer, select preferences , compatibiltiy tab, check "disable visual themes"). then, try running application , you'll notice starts crashing when try show openfiledialog or savefiledialog.
visual themes may turned off @ os level (when using high contrast theme instance) , turned off in terminal services sessions, or when desktop sharing via webex or other desktop sharing applications.
unfortunately don't have solution yet based on reading through msdn looks microsoft saying should "provide alternative code path" when desktop composition , visual themes off - whatever means.
internally, openfiledialog's implementation has method attempts initialize instance of open file dialog com control fails when visual themes off
[securitycritical, securitytreatassafe] internal override ifiledialog createvistadialog() { new securitypermission(permissionstate.unrestricted).assert(); return (ifiledialog) activator.createinstance(type.gettypefromclsid(new guid("dc1c5a9c-e88a-4dde-a5a1-60f82a20aef7"))); }
Comments
Post a Comment