views:

674

answers:

4

In Visual Studio 2008, all of a sudden, when I try to Add Existing Item to a project, I'm getting this error:

The operation could not be completed. ClassFactory cannot supply requested class

Since I installed VS 2010 Beta 2 yesterday, I just now did a system restore to before that point to see if that was the cause. It wasn't.

I think I know what caused this, but I don't know how to fix it. I think it was caused by trying to fix another Visual Studio problem, as described in this thread:

AnswerEvent log error 4201 - ERROR WMI INSTANCE NOT FOUND

I ran the long procedure described in the post starting with "OK Ladies and Gentleman, here is what we have found;". It fixed a problem I was having with Server Explorer not working, but I think it may have caused my current problem due to a permissions issue.

If so, does anyone know what permission I need to fix? Is there a way I can find out? Or do you have any other ideas about what I can do to solve this? (I haven't tried a repair install yet, because I'm hoping for a solution that won't take that long.)

+1  A: 

Using the Process Explorer from these SysInternals tools you can see what files and registry settings applications attempt to access, and filter for failed attempts. It is an overwhelming amount of information at first, but it gives you a pretty complete picture of everything an application is attempting to do, and you can begin to look at failures to open/read files/registry settings to help determine the cause of problems like this. Then of course you can look at the permissions on each file or registry key(yes, registry keys have permissions just like files, and this can cause problems so watch out for that) and loosen the permissions to try and resolve the problem.

Edit: You should check the permissions for those keys. Note that you have permissions for different users/roles. If I belong to both administrators and users groups, and the administrator group has Read permissions, but the user group has a Deny checkbox for read permissions, then the deny actually takes precedence and will prevent your account from accessing the registry key. The same concept goes for "Full Control" permissions in the case that the program is trying to write a value to the registry key. I think there should be something in the failure that indicates what it was trying to do with the key.

I also have it under "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}". and under that there is this, HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}\InProcServer32\ which has a default value of "%SystemRoot%\System32\comdlg32.dll". This is how an application finds the dll for a class. It looks it up via the GUID, and the path tells it what DLL to load the class from. So make sure that the path listed actually has that DLL there, and the DLL file has appropriate permissions as well. Again, check all the groups/roles that are listed in the permissions dialog to ensure that none have a checkbox in the Deny column, and that the Allow column is checked to allow read access for at least one of the roles you belong to.

AaronLS
How do I "filter for failed attempts"?
Kyralessa
Ah, you must've meant Process Monitor.
Kyralessa
In the two places where it fails, the common thread seems to be a problem with something that has this GUID: {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}
Kyralessa
That could be alot of things, but I would start with a search of your registry for that guid in regedit.
AaronLS
I did that as soon as I found it; it's under HKCR\CLSID, HKLM\SOFTWARE\Classes\CLSID, and HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer>FileOpenDialog. The first two just have the key with "File Open Dialog" as the value, and the last has that GUID as the value for the File Open Dialog item. ...I wonder if it's *missing* from somewhere. Would you mind searching for it on your system to see where it shows up?
Kyralessa
See edit since I have limited room in comments.
AaronLS
That looks very promising. I'll try creating that value tomorrow and see what happens. (I'm surprised this hasn't apparently broken any other programs besides VS, though. I would've thought that several other Microsoft programs, such as Office, use the same dialog.)
Kyralessa
Alas, it turns out I had the InProcServer32 stuff after all, and my permissions appeared to be OK. User only had Read while others had Full Control, but none of them had Deny. The permissions on the DLL appear to be fine as well.
Kyralessa
I don't know why someone voted this down. It's not the complete answer, but it's certainly a good start.
Kyralessa
That was me... I meant to downvote the "CHECK THIS OUT BUDDY!" answer and I guess I hit this one? As soon as the author edits his answer I should be able to change it. Sorry about that.
Anderson Imes
Anderson, FYI you can remove downvotes.
AaronLS
You can't remove downvotes after 5 minutes unless the author edits the answer.
Anderson Imes
A: 

(I haven't tried a repair install yet, because I'm hoping for a solution that won't take that long.)

Repairing your Visual Studio installation seems to be the best solution at this point if you haven't already found the solution- It seems that you have already invested more time into tracking down the offending .dll than it would take to repair the installation.

I searched for a solution to your problem for a couple hours (and it seems that you have too- there's hardly a related forum without a post from you on it) just now and found nothing that was specific to your symptoms that you haven't already tried.

Diakonia7
A: 

We usually fix that problem by running:

On Windows XP:

secedit /configure /cfg %windir%\repair\secsetup.inf /db secsetup.sdb /verbose

On Windows Vista:

secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose

As administrator. Please be sure not to stop it half way through, and backup your registry before doing so.

This will recover all the registry permissions, which cause most WMI problems usually.

Alex Bagnolini
Which problem is this supposed to fix? The WMI instance not found problem? Because that problem's already fixed. The ClassFactory problem is the problem I actually posted about.
Kyralessa
A: 

Enabling the "Disable visual themes" checkbox on the devenv.exe compatibility settings causes this issue.

See: http://connect.microsoft.com/VisualStudio/feedback/details/532500/visual-studio-responses-with-classfactory-cannot-supply-requested-class

This is unfortunate, because the Visual Studio 2008 UI is noticeably more responsive with visual themes disabled.

TickleMeElmo