Trying to Add a Reference to Visual Studio Project Suddenly Throws an Exception - visual-studio

When I try to ADD a REFERENCE to any Visual Studio project...I am suddenly getting the following exception:
Error HRESULT E_FAIL has been returned from a call to a COM component
This happens across ALL projects regardless of whether they are source-controlled (or not)
SIDE NOTE:
I did recently install Xamarin on a SEPARATE PROJECT in another TFS SOLUTION
WHAT I'VE DONE SO FAR:
Delete all *.suo files
Delete all *.user files
Wiped the TFS Workspace & done a FORCE GET
Nothing has worked

The FIRST TIME you get this error message you'll get a window with a reference to the following file:
ActivityLog.xml: This file contains information about the underlying error.
If you ignore the message & click away from the initial dialog, THE ERROR GETS SUPPRESSED and is replaced with:
Error HRESULT E_FAIL has been returned from a call to a COM component.
If you look in this file you will see the error. This particular exception was was caused by:
Microsoft.visualstudio.shell.interop.IVsReferenceManager2
Within the Microsoft.VisualStudio.Shell.Interop.11.0.dll library.
This post helped me solve the issue!
THE FIX IS:
Open "Developer Command Prompt for VS 2017" as an Administraor
CD into "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"
Run "gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll"
After a restart, it all worked well.

Related

System.IO.IOException during the build process in VisualStudio 2017

I'm working on a Hololens application using Unity 2018.2.20f1. I'm building the application for UWP from Unity without a problem. However, after opening up the generated solution in the VisualStudio 2017 (Community Edition) and trying to build it, the build process fails with the following errors:
Severity Code Description Project File Line Suppression State
Error MSB3073 The command ""D:\Projects\VSProjects\VirtualPrague\Il2CppOutputProject\\IL2CPP\build\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=x86 -configuration=Release -platform=winrt -outputpath="D:\Projects\VSProjects\VirtualPrague\\build\bin\Win32\Release\GameAssembly.dll" --data-folder="D:\Projects\VSProjects\VirtualPrague\\build\bin\Win32\Release\\" -cachedirectory="D:\Projects\VSProjects\VirtualPrague\\build\obj\il2cppOutputProject\Win32\Release\\" -generatedcppdir="D:\Projects\VSProjects\VirtualPrague\Il2CppOutputProject\\Source" --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityjit -verbose --map-file-parser="D:\Projects\VSProjects\VirtualPrague\Il2CppOutputProject\\IL2CPP\MapFileParser\MapFileParser.exe"" exited with code -532462766. Il2CppOutputProject C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets 44
and
Severity Code Description Project File Line Suppression State
Error LNK1181 cannot open input file 'D:\Projects\VSProjects\VirtualPrague\build\bin\Win32\Release\GameAssembly.lib' VirtualPrague D:\Projects\VSProjects\VirtualPrague\VirtualPrague\LINK 1
In the output there are multiple exceptions, similar to this one:
1>il2cpp.exe didn't catch exception: System.IO.IOException: The process cannot access the file 'C:\Users\dev\AppData\Local\Temp\tmpDE97.tmp' because it is being used by another process.
1> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
1> at System.IO.File.InternalDelete(String path, Boolean checkHost)
1> at Unity.IL2CPP.Shell.Execute(ExecuteArgs executeArgs, IExecuteController controller)
1> at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
1> at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
1> at il2cpp.Program.DoRun(String[] args)
1> at il2cpp.Program.Run(String[] args)
1> at il2cpp.Program.Main(String[] args)
The exceptions are the same but were thrown for different files. I tried to reinstall the Visual Studio and managed to get a build. The next day I turned on the PC and this error was back. I stopped all of the VS instances and processed from the task manager, deleted all of the files from the Temp folder and managed to get a build a couple more times. Then this error came back.
From what I can tell, during the build process, Visual Studio creates some *.tmp files and for some reason thinks that another process is using it.
Any idea why this is happening and how can it be solved?
Thanks a lot!
Edit: So here is what I did so far (this is more of a work around rather then a solution)
Uninstall vs and unity
Clear the registry with ccleaner and Advanced Uninstaller Pro
Install vs and Unity
Every time I want to get a build I,
Close all of vs instances
Clear Temp folder (C:\Users\dev\AppData\Local\Temp)
Delete previous vs solution
Build from Unity
Run vs as Administrator
Build and deploy the solution from vs
And it works for the most the time. Also, changing the solution configuration (from debug to release and vice versa) helps sometimes.

Unable to debug .NET Core app

I'm having and issue with Visual Studio and a .NET Core API project. It's been working fine but something must have changed because I'm now getting the following output when trying to debug the project:
The program '[18032] dotnet.exe' has exited with code -2147450749 (0x80008083).
The program '[17688] iisexpress.exe' has exited with code 0 (0x0).
The program '[5500] iexplore.exe' has exited with code -1 (0xffffffff).
The event viewer is showing this error:
Failed to start process with commandline '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe" -debug -p "C:\Program Files (x86)\dotnet\dotnet.exe" -a "C:\Projects\Utilities\API\src\API\bin\Debug\netcoreapp1.0\API.dll" -pidFile "C:\Users\username\AppData\Local\Temp\tmp742C.tmp" -wd "C:\BlueSky\Utilities\API\src\API"', ErrorCode = '0x80004005'.
I'm not sure why this is happening, if anyone has any insight into this it would be appreciated.
Do as fallow:
Close Visual Studio
Delete the project.lock.json file (if exists)
If above step won't help then try to remove .vs folder
Open Visual Studio as Administrator (the file will be restored and you shouldn't have problems anymore)
There is also an option to use Kestrel instead of IIS Express but that's just an workaround.

Metadata file .dll cannot be found CSC error

I am getting CSC errors when trying to build my project. I have reference numerous threads here including this one on metadata error dll not found.
I have checked build dependencies, unchecked and re-checked projects under Configuration Manager, checked environment variables for %VS120COMNTOOLS%, confirmed Path and C:\Windows\system32... I'm still getting a CSC error.
The error says that "Metadata file 'C:\Users\Username\Source\Workspaces\CompanyName\Main\CompanyDataModel\bin\Debug\CompanyDataModel.dll could not be found".
I've also looked and seen that I have a similar script as mentioned in this thread in my .bat files. For example, the VCVarsQueryRegistry file has for loops like this:
#for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" /v "InstallationFolder"') DO (
#if "%%i"=="InstallationFolder" (
#SET "WindowsSdkDir=%%k"
)
)
Are these variables the problem? I tried to edit these for loops but right clicking and then Run as Administrator only brings up a blank command prompt and then it disappears. If I try to edit in Notepad, I get "Access denied" when I go to save the file.
What is causing these CSC errors?
As a last resort, I decided to download Visual Studio Ultimate 2013. (I was using Visual Studio Community 2013) After restarting Visual Studio Ultimate 2013, the metadata errors were still showing.
I then signed out of my Microsoft account and signed back in. I opened Visual Studio Ultimate 2013... and errors eliminated!

F# Microsoft.ParallelArrays not defined

So I downloaded and installed Microsoft Accelerator v2 to use ParallelArrays. I have referenced it in my project but when I try and execute the code from the module in a script file I get:
"The namespace 'ParallelArrays' is not defined
I have followed the instructions on this post:
Microsoft Accelerator library with Visual Studio F#
I've added a reference to the managed version "Microsoft.Accelerator.dll" to my F# project and then added the native "Accelerator.dll" as an item in my solution and set it's 'Copy To Output Directory' to Copy Always.
Still getting the FSI error and inline error in my script file on the '#load ...' line, however the solution builds fine, and no error in the module file.
Any ideas on what I'm missing? I'm sure it's something stupid.
Thanks,
Justin
UPDATE
I tried mydogisbox's advice, which got rid of the error above, but now when I run the code in the .fsx file I get this error instead:
--> Referenced 'F:\Work\GitHub\qf-sharp\qf-sharp\bin\Debug\Microsoft.Accelerator.dll' (file may be locked by F# Interactive process)
[Loading F:\Work\GitHub\qf-sharp\qf-sharp\MonteCarloGPU.fs]
error FS0192: internal error: F:\Work\GitHub\qf-sharp\qf-sharp\Accelerator.dll: bad cli header, rva 0
UPDATE 2
So the bad header error has dissapeared, but now I get this instead:
Microsoft.ParallelArrays.AcceleratorException: Failure to create a DirectX 9 device.
at Microsoft.ParallelArrays.ParallelArrays.ThrowNativeAcceleratorException()
at Microsoft.ParallelArrays.DX9Target..ctor()
at <StartupCode$FSI_0002>.$FSI_0002_MonteCarloGPU.main#() in F:\Work\GitHub\qf- sharp\qf-sharp\MonteCarloGPU.fs:line 14
Stopped due to error
I found this thread on MSDN however the answers proposed as fixes on that thread barely even relate to the question.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/98600646-0345-4f62-a6c5-f03ac9c77179/ms-accelerator?forum=csharpgeneral
My Direct X version is 11, and I imagine that will suffice, however I tried installing DX9 however, it tells me that a newer version is detected therefore cant install.
There are special directives for referencing dlls from fsi. The #load directive loads the .fs file only. You need to use the #r directive to reference the file. You can either use the full path of the file or you can use #I to include the path to the file. More details here. Keep in mind that fsi is completely independent of your project, so all references in your project must be duplicated in fsi for it to access the same types.

Visual 2010 MFC new project doesn't build!

I just created a new project in Visual 2010. It is a multi-document MFC (static link) application with the HTML help option, Visual Studio 2008 style (with style changing option), that's about it.
Just after creation, I hit Build Solution and I get a lot build errors all in afxcomctl32.h. Errors like:
Error 1 error C2061: syntax error : identifier 'LPCWS' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxcomctl32.h 426 1
On this line:
AFX_ISOLATIONAWARE_STATICLINK_FUNC(HWND ,CreateWindowExW,(DWORD dwExStyle,LPCWS TR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam),(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam),NULL)
Same errors in Debug and Release.
My PC is Windows 7 Ultimate. What's the problem???
Best regards,
Downy
AFX_ISOLATIONAWARE_STATICLINK_FUNC(..., LPCWS TR lpClassName, ...)
That code got messed up, there is a space or tab inserted in LPCWSTR. Deleting it will fix the problem.
However, that changed the timestamp on the file as well, you may run into trouble when you install a future service pack. One thing to try is to rename the file, then run a Repair to get the original file back. Or copy it off another machine.

Resources