1097

This morning I faced a problem while opening my Visual Studio solution, and when I tried to run it, it said:

No exports were found that match the constraint contract name

How can I fix this problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Simon B.Robert
  • 31,754
  • 4
  • 16
  • 24

26 Answers26

2198

I solved this problem by clearing Visual Studio Component Model Cache.

Just delete or rename this folder:

%LocalAppData%\Microsoft\VisualStudio\11.0\ComponentModelCache

or

%LocalAppData%\Microsoft\VPDExpress\11.0\ComponentModelCache

and restart Visual Studio.

The version of Visual Studio you have is specified by the number e.g.

Visual Studio 2012 is 11.0 (as shown above)

Visual Studio 2013 is 12.0

Visual Studio 2015 is 14.0

Visual Studio 2017 is 15.0

Visual Studio 2019 is 16.0

For those that don't know: %LocalAppData%\ is the same as C:\Users\{yourUsername}\AppData\Local

For those who have multiple versions of Visual Studio installed, e.g. 2012 and 2013, it might help to remove the ComponentModelCache for both versions before restarting Visual Studio, e.g. 11.0 and 12.0.

w00ngy
  • 1,646
  • 21
  • 25
Simon B.Robert
  • 31,754
  • 4
  • 16
  • 24
  • 20
    Worked for me, too, but for the express version of VS Desktop Developer, I found the cache data in ...\AppData\Local\Microsoft\WDExpress – josiah Jul 18 '13 at 22:42
  • 4
    i cant open my c++ files after **delete all** in that folder, when i restore these files except Microsoft.VisualStudio.Default.cache, then reopen my solution then everything back to normal. – Scott 混合理论 Jul 22 '13 at 11:14
  • 2
    Deleting the Microsoft.VisualStudio.Default.cache file solved the problem – Tim Valentine Aug 15 '13 at 15:06
  • I renamed C:\Users\username\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache\ and the problem went away. I listed the full path here in case anyone else needs it. AppData is hidden, but if you type it in Windows Explorer it can be traversed. – Mark Aug 26 '13 at 17:01
  • 1
    @alexo, appears for me after installing .net 4.5.1 dev pack on vs 2012 – mt_serg Feb 28 '14 at 15:45
  • @alexo In my case, the only reason I could think of why this issue would occur is because there was still a service / server running on your localhost or that atleast some resources were in use, which did not end correctly when shutting down your PC / Laptop. – lt.kraken Mar 04 '14 at 11:04
  • @Simon, it worked very well with this: '%AppData%\..\Local\Microsoft\VisualStudio\11.0\ComponentModelCache' I just removed than boo. worked! – Helder Robalo Mar 19 '14 at 13:01
  • @RobertFricke I think you should edit the answer and include that (even though it might be obvious, but still) – Dimitar Dimitrov Aug 23 '14 at 13:17
  • Should remove also : ...\AppData\Local\Microsoft\VWDExpress\12.0\ComponentModelCache for those working with the express version of VS – minchiya Oct 18 '14 at 13:03
  • Thanks this solved my problem. I just want to add that my cause of this problem might be that i recently updated my windows. It occurred on the same day. In this update i did update for Microsoft .NET Framework 4.5.2 for Windows 7 x64-based Systems. even when i restarted my computer this problem was still there. I might be wrong but mt_serg mentioned installing .Net too. During install VS2013 was opened. – Tomas Kosar Jan 15 '15 at 11:42
  • Thanks. I spent the last couple of hours doing everything from reconnecting TFS to downloading new files to running it in admin mode etc. Just renaming the ComponentModelCache folder for VS13 worked. – Octane Mar 16 '15 at 07:39
  • God bless your cotton socks. This has happened to me several times and every time I ran a whole Visual Studio "repair", losing several hours of work. BTW, this is in VS 2013 - i.e. the bug that causes this is still on the loose! – Shaul Behr Apr 22 '15 at 12:58
  • 1
    It took machine restart in my case after following above steps! Thanks!! – sandeep talabathula Dec 02 '15 at 13:29
  • Thanks, it work. it happen to me several times after windows update. And i keep visiting this thread :) – David Feb 10 '16 at 13:52
  • Thanks for that! This error happened after I installed an update to fix my IE11 browser console window! The Micro$oft love-hate relationship carries on.... – hatsrumandcode Feb 17 '16 at 12:17
  • it works for me also. I have just renamed %AppData%\..\Local\Microsoft\VisualStudio\15.0\ComponentModelCache to another name. For Visual Studio 2016 (15.0) – Banketeshvar Narayan Apr 17 '16 at 16:14
  • Couldn't find the folder for 2013 at the given location but using a search from ..local did the trick ;-) – TaW May 13 '16 at 08:04
  • This has also fixed my issue of Node.JS interactive window, which used not show up. – dance2die Jul 24 '16 at 13:14
  • BTW, this started happening to me after removing Node Tools for Visual Studio. So probably a lot of things that muck with plugins may cause it. This solution worked. – Darren Clark Aug 22 '16 at 23:28
  • I got this issue after installing SSMS 2016, which runs on VS 2015 shell. I am using VS 2013 on this machine. Though it may have been caused by shutting down my machine and not waiting for VS to completely close or an update. – RIanGillis Aug 29 '16 at 13:42
  • 4
    This extension does this automatically for you with one click (including restarting VS): Clear MEF Component Cache https://visualstudiogallery.msdn.microsoft.com/22b94661-70c7-4a93-9ca3-8b6dd45f47cd – kzu Sep 01 '16 at 16:24
  • 1
    Works like a charm. Thank you so much. I got this issue after installing Team Foundation Server. – jayvee Nov 21 '16 at 05:23
  • Thanks... Was looking for same,,,,i my case Power Productivity tool was main problem – kplshrm7 Oct 15 '18 at 05:49
  • In my case VS2019 the folder was named 16.0_8ab085c4 – Andrei Bazanov Oct 29 '19 at 10:57
154

No need to rename or delete the whole folder:

(%AppData%\..\Local\Microsoft\VisualStudio\11.0\ComponentModelCache)

Just rename or delete the Microsoft.VisualStudio.Default.cache file inside the above location.

Macmade
  • 52,708
  • 13
  • 106
  • 123
73

Visual Studio Express 2012 has different paths.

Visual Studio Express

  • ...\Users\{user}\AppData\Local\Microsoft\WDExpress\11.0\ComponentModelCache

With Visual Studio Express 2012 for Web

  • ...\Users\{user}\AppData\Local\Microsoft\VWDExpress\11.0\ComponentModelCache

I did not have to re-install Visual Studio Express

37

This will really work like a champ:

Solution: Try to delete ComponentModelCache folder from the below location.

[C:]\Users\[your user name]\AppData\Local\Microsoft\VisualStudio\[Visual Studio version number]

And after successful delete, recreate the folder with the same name, "ComponentModelCache".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hadi Salehy
  • 917
  • 11
  • 10
  • This is the same as [the highest-voted and accepted answer](https://stackoverflow.com/a/17604007/150605), as well as a few other contemporary answers. – Lance U. Matthews Jun 06 '22 at 22:31
28

Deleting the Component Model Cache did not work for me (well, the relative directory given above did not exist in my machine). Instead, I installed an extension to Visual Studio 2012 Express. Menu ToolsExtensions and Updates...OnlineChoose any and then download. This apparently invalidates the cache causing Visual Studio to rebuild it.

Here's my source.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nicola
  • 851
  • 7
  • 11
  • 1
    Visual Studio --EXPRESS-- has a different location. Check the other answers in this thread. – Pure.Krome Dec 30 '13 at 05:46
  • In my case it happened after install xamarin extention in VS2015 comunity. after remove all goes well. I remove it in the same place that in this answer. Tools > Extensions and Updates – Ricardo Figueiredo Sep 03 '16 at 19:04
28

This issue can be resolved by deleting or clearing all the folders and files from %AppData%\..\Local\Microsoft\VisualStudio\11.0\ComponentModelCache

This actually clears the Visual Studio component model cache.

On Windows 7 machines, the path is different. When you type %appdata% in Run dialog, it opens the folder C:\Users\<username>\AppData\Roaming.

Click the 'up' button to navigate to the parent folder and select the folder 'Local'.

Final path: C:\Users\<username>\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
myaseedk
  • 1,948
  • 1
  • 14
  • 12
21

For Visual Studio 2013 you need to remove that folder from this path:

%AppData%\..\Local\Microsoft\VisualStudio\12.0
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Arun Rana
  • 8,426
  • 14
  • 67
  • 107
  • 1
    I experienced this after my battery ran out installing a rather large xamarin update for vs2013. Went into this folder, renamed the ComponenetModelCache and upon restart it recreated the folder and it was fixed. Ty – Dylan Hayes Mar 06 '14 at 16:32
  • Also worked for another error for me: `'visual c++ package' failed to load` – JTIM Jul 21 '15 at 08:03
20

for Visual Studio 2012 and later versions, the solution must be deleting the content of the folder ComponentModelCache:

C:\Users\[username]\AppData\Local\Microsoft\WDExpress\11.0\ComponentModelCache

Visual Studio 2013

C:\Users\[username]\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
16

I had the same problem upon launching Visual Studio 2013 Ultimate, and the solutions here didn't work for me. I tried deleting the mentioned folders and starting Visual Studio again, but it didn't work.

However I had other problems too, like Microsoft.visual studio package did not load correctly and also Page '312e8a59-2712-48a1-863e-0ef4e67961fc' not found VS 2012. The latter refers to a message in the Team Explorer window saying "Page 'somenumber' cannot be found".

So I run devenv /setup on the Visual Studio command prompt with administrative rights. It did the job, and everything is fine now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jbarrameda
  • 1,927
  • 2
  • 16
  • 19
  • I was deleting the folder specified (Win 8.1, VS 2013 Prem) and it kept coming back every time I closed and re-opened VS. This unfortunately did not work either. – bdwakefield Mar 05 '15 at 20:32
  • 1
    After trying several solutions did was the trick that solved my problems. Because the VS Command Prompt for VS2013 isn't easy to find here is the path to it: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts – Tarabass Jun 15 '15 at 11:59
  • devenv /setup fixed a crashing problem with VS 2015 Pro for me. The ComponentModelCache was not fixing it. – Zach Green Jun 30 '16 at 13:59
  • Wow - didn't expect this to work, but it did! VS 2017 Community edition. – scolja Sep 14 '18 at 04:19
13

Remove ComponentModelCache folder content.

 %AppData%..\Local\Microsoft\VisualStudio\11.0\ComponentModelCache
Ali
  • 1,265
  • 14
  • 18
11

Clearing the folders didn't work for me. So I went to 'Programs and Features' and used the change button to startup the Visual Studio 2013 setup.

In the setup I choose the repair function and that fixed the problem for me.

C. Molendijk
  • 2,614
  • 3
  • 26
  • 35
9

I had the same problem with Visual Studio Express 2013 of Windows 8.1.

Unfortunatly there was no "ComponentModelCache" folder in
%AppData%..\Local\Microsoft\VisualStudio\12.0\ComponentModelCache.

I found the "ComponentModelCache" folder in
..\Users[username]\AppData\Local\Microsoft\WDExpress\12.0

and solved this problem by removing this folder from there.

fose
  • 730
  • 1
  • 10
  • 24
8

If you have VS 2013, you have to go to: %LOCALAPPDATA%\Microsoft\VisualStudio\12.0 then rename the ComponentModelCache folder.

Rouse02
  • 157
  • 2
  • 7
  • +1 for %LOCALAPPDATA% , I was using %AppData% and didnt find any folder like ComponentModelCache. But using %LOCALAPPDATA% I can get it. – Rajshekar Reddy Jan 07 '16 at 10:26
7

I experienced a similar problem after some updates released from Microsoft (part of them where about .NET framework 4.5).

On the Internet I got the following link to the Microsoft knowledge base article:

Update for Microsoft Visual Studio 2012 (KB2781514)

It worked for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Filippo
  • 1,123
  • 1
  • 11
  • 28
  • 1
    +1 - Great find! This solved the problem for me. It is the legitimate solution instead of hackishly deleting the cache file which could have implications in the future. – Travis J Oct 30 '13 at 14:27
  • Except that this problem still exists in VS2015, so this is unlikely to be the 'legitimate solution'. – Neil May 13 '16 at 13:07
6

This happened to me with Visual Studio 2013 Web, after Windows installed several updates. Unfortunately none of the suggestions in this thread helped.

I had to re-run the installer and select the "Repair" option. After that (and a reboot) it was working once again.

In some cases you may have to repair more than one version of Visual Studio. One example is when a Script Task control in VS 2013 opens VS 2012 when you click Edit Script.

El Jefe
  • 1
  • 2
easuter
  • 1,167
  • 14
  • 20
4

Renaming the ComponentModelCache folder worked for me in Visual Studio 2015, but with a slightly different path:

%AppData%\..\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
Robotnicka
  • 554
  • 1
  • 10
  • 20
3

I have Windows 7 x64 with a second partition on which Windows 8 (preview installed). While working with Microsoft Visual Studio Express 2012 for Windows Phone, I come up with the same problem. But the ComponentModelCache is found here:

C:\Users\Jayaram\AppData\Local\Microsoft\VPDExpress\11.0

I am unable to delete or rename as I get the "access is denied" message when I try to use command prompt:

Administrator: VS2012 X64 CrossToolsCommandPrompt

user2063329
  • 443
  • 2
  • 5
  • 15
3

I am using Visual Studio 2012. After installing the Visual Studio 2013 web express, when I want to run or open any project in Visual Studio 2012 it shows me the following error:

"no exports were found that match the constraint contract name".

I also tried the above solution for clearing the ComponentModelCache, but I did not find the folder. I solves my problem just by: Repair Visual Studio 2012

For the Express versions of the software, the folder you need is in a slightly different place(s): For Express 2012 for Web it is C:\Users\XXXXXXXX\AppData\Local\Microsoft\VWDExpress - not in the Visual Studio folder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mohammad Atiour Islam
  • 5,380
  • 3
  • 43
  • 48
  • 1
    it happened for me in 2013 with that being the only visual studio installed on my machine - did repair, as you mentioned via the "uninstall a program" panel and it was fixed. – Dave Rael Feb 17 '14 at 18:17
  • I didnt find the folder too initially by using %AppData% but by using %LOCALAPPDATA% I could naviagte and find the folder – Rajshekar Reddy Jan 07 '16 at 10:29
  • bingo,,,,this one is more accurate answer for me – Rohit Kumar Jan 27 '18 at 15:49
3

This issue is because of a MEF cache corruption. Installing the feedback extension (or installing any extension) will invalidate the cache causing VS to rebuild it.

click for source.

emy
  • 664
  • 1
  • 9
  • 22
3

i experienced this problem in Microsoft Visual Studio Express 2012 for windows phone while trying to open file.

Then i browsed to

C:\Users\MyUserName\AppData\Local\Microsoft\VPDExpress\11.0\ComponentModelCache

And Inside ComponentModelCache i deleted Microsoft.VisualStudio.Default.cache CACHE file. Finaly i restarted visual studio and reopened my project.

Then my problem was solved, i was able to open file.

Note: My OS is windows 8. And i installed SDK 8 for developing windows phone app

Thanks

Espo
  • 41,399
  • 21
  • 132
  • 159
Rashedul.Rubel
  • 3,446
  • 25
  • 36
2

I got an error with the same error message - two years later. It's a different problem this time though, related to .NET Core dnx things.

I couldn't find an answer on Stack Overflow, but there's a GitHub issue that contains a workaround: https://github.com/aspnet/Home/issues/1455

Below is the most important part of the workaround:

  • Delete the entire C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\DNX directory. (As far as I understand, it belongs to the old version of ASP.NET Core RC1, which for some reason is still shipped even with Visual Studio 2015 Update-3).
  • Delete the C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\14.0\devenv.exe.config file.
  • Run the Developer Command Prompt for Visual Studio 2015 as Administrator, and execute the devenv /setup command. The new devenv.exe.config file is generated. This time there are many assemblies that refer to the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\DotNet directory.
  • Run the Visual Studio 2015 and check that it shows the Microsoft .NET Core Tools (Preview 2) 14.1.20624.0 in the Help => About Microsoft Visual Studio menu.

Thanks to olegburov's post on GitHub for figuring this out.

Matty
  • 505
  • 1
  • 10
  • 16
1

I had to uninstall some external components like Postsharp and Apex and then it worked. I also tried the chosen solution but it gave me more errors.

Revious
  • 7,816
  • 31
  • 98
  • 147
1

Deleting the folders haven't worked for me i have go control panel and repaired

Visual Studio Installer Projects extensions for VS 2013.

And it worked for me

Vivekh
  • 4,141
  • 11
  • 57
  • 102
0

I got this error after reinstalling IntelliJ IDEA and ReSharper for C# in Visual Studio 2013.

First, I got an error problem with extensions, and after this I got this error:

"No exports were found that match the constraint contract name”

I simply removed folder ComponentModelCache and resolved this error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ihor Levkivskyi
  • 341
  • 5
  • 14
0

My 2 cents: Following all above lifesaving tips, I had a slightly different experience; mine is VS 2017 Community Edition, installed once, and I notice that have all these 3 folders:

%LocalAppData%\Microsoft\VisualStudio\15.0 ==> Empty
%LocalAppData%\Microsoft\VisualStudio\7f0c75b0 ==> has only the CoreCon folder

This is the one that has the ComponentModelCache:

%LocalAppData%\Microsoft\VisualStudio\15.0_7f0c75b0

Deleting only the Microsoft.VisualStudio.Default.cache had no effect.

So, I deleted all 4 files there: .cache, .err, .external and catalogs. On restarting VS, problem gone and appeared a 5th file:

Microsoft.VisualStudio.Default.scan
0

Removing ComponentModelCache did not work for me. Reinstalling VS 2019 did thanks to a recommendation on this Microsoft support thread.

Details

  • This seems to be a known bug with a fix incoming from MS (as of 1/7/2020)
  • Experienced after upgrading from VS2019 Pro 16.2 (i think it was?) to 16.4.2 using Visual Studio Installer
  • Error displayed when trying to launch both nuget console and nuget package manager
w00ngy
  • 1,646
  • 21
  • 25