2

So I tried making a basic game on the console using screen buffers, I was able to create it and make a square move in the canvas, but for my next project I looked up a website with the ASCII characters and pasted a couple into a comment at the end of the c++ file, when I ran the file visual studio prompted: visual studio prompt

I clicked yes and it didn't run anymore. Also I recently have installed an extension for visual studio (before it didn't run, the extension works fine but I don't know if the extension may have caused this as I didn't tried running it with the extension downloaded and applied), when I open visual studio and open a file it says: vs file open

The last record in the ActivityLog xml file, has a type of error and it's description is:

Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name "Microsoft.VisualStudio.CppSvc.Internal.CodeAnalysis.ICodeAnalysisService" but found 0 after applying applicable constraints. at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition) at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality) at
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName) at
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T](String contractName) at
Microsoft.VisualStudio.Composition.ExportProvider.GetExportT at
Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValueT at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetServiceT at Microsoft.VisualStudio.VC.ManagedInterop.<>c.<Initialize>b__52_15() at
System.Lazy`1.CreateValue() at
System.Lazy`1.LazyInitValue() at
System.Lazy`1.get_Value() at
Microsoft.VisualStudio.VC.CodeAnalysis.ResultTaggerProvider.CreateTagger[T](ITextBuffer buffer) at
Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer) --- End of stack trace from previous location where exception was thrown --- at
Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

I have Visual Studio 2017 So why does running the file (with the local windows debugger button) say that there were build errors? And how can I fix it? When it prompts the build error, and I click no it usually shows the errors but in this case it doesn't, yes will just run the last "successful" build (although I haven't changed the file since I have finished it before this error message started popping up) Also there is no error in my code as I was able to run it before the build error kept appearing and I haven't touched the file since(only now to show the problems are)

Thanks for your time! if anything was unclear because of my English, comment and I'll try to clarify it

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
lolfail
  • 124
  • 2
  • 12
  • 1
    What are the build errors? Can you edit the exact error message into your question? Can you also include an example of the lines the errors are on, maybe with a few lines context around them? – Rup Jun 19 '20 at 10:20
  • 1
    I'd also suggest resaving the file as UTF-8 in case that makes a difference (in case your extension is failing to parse a UTF16 file), or identifying and removing the non-ASCII characters and going back to the default codepage. – Rup Jun 19 '20 at 10:32
  • 1
    _"...website with the ASCII characters ..."_ nope you pasted Unicode. Don't put these in your source files put them in an external file instead and read them in. Be careful on MS-Windows using UTF-8 as Windows is native UTF-16 (UTF-8 is possible with some extra work). – Richard Critten Jun 19 '20 at 10:44
  • @Rup There are no errors as I wrote in my question no lines are red and when I click no when it prompts because of build error It doesn't show the errors when in other projects it should. I have already removed the extension but that didn't fix it – lolfail Jun 19 '20 at 18:41
  • OK. Can you check the Output tab? If there’s nothing there, can you try building the project from a Visual Studio command prompt? There must be some output. – Rup Jun 19 '20 at 18:48
  • @Rup it only says Object reference not set to an instance of an object which is weird considering there were no errors yesterday and I haven't edited this file since then, also I have tested creating a new console project, leaving it as it is and running it with only a `std::cout` gives the same output – lolfail Jun 19 '20 at 18:55
  • 1
    That’s a runtime error not a compile time error - you’ve hit a bug in the compiler or build system or Visual Studio then. I’d roll back to yesterday’s version of the code then if you have a commit, else I’d copy and paste this into a new file without the new lines - retype them rather than copy and paste - and don’t save as Unicode. – Rup Jun 19 '20 at 18:58
  • @Rup I've created a new file just to see if it would work, included iostream, created the main function, std::cout -ed "test" and returned 0 it says the same thing, I think the problem isn't with the code I have also tried resetting all of my settings to default using the built in tool for it – lolfail Jun 19 '20 at 19:19

1 Answers1

1

I fixed the error by deleting ComponentModelChache folder located at:

C:\Users\%userName%\AppData\Local\Microsoft\VisualStudio\15.0

15.0 is the version of your visual studio so it varies depending on the version you're using, %userName% is a replacement for the user you're logged in as

lolfail
  • 124
  • 2
  • 12
  • Thanks, that worked for me too. But VisualStudio needed to be restarted after deleting the cache. For the same problem see this topic also [link](https://stackoverflow.com/questions/17596543/error-message-no-exports-were-found-that-match-the-constraint-contract-name) – tom2051 Jun 15 '21 at 13:27