Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You might upgrade your Visual Studio Project to VS 2017 and you might get errors like:
1>c:\memspect\vsassert\pch.h(20): fatal error C1083: Cannot open include file: 'metahost.h': No such file or directory
On machine with an older version of Visual Studio, I found metahost.h at:
c:\Program Files (x86)\Windows Kits\8.1\Include\um\metahost.h
Looking at the file, I see that there are definitions of many CLR interfaces for using native code with .Net, like ICLRMetaHost (See .Net Unmanaged API Reference)
I found the file on the VS 2017 machine at:
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
Apparently it used to be part of the Windows 8.1 SDK, but is now in the .Net SDK. Seems like a reasonable change, but now I understand why it breaks backward compatibility.
Check to see if you have a version of the .Net SDK with metahost.h installed. If not, run the Visual Studio installer to install a .Net Framework SDK version.
On my machine the installer is "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe"
Choose to modify your installation, then go to the Individual Components page. There are a whole bunch of choice for .Net:
Then you can go to the Project->Properties->Configuration Properties->C/C++->General/Additional Include Directories, and paste in the path to the new file.
Of course another way to fix this problem is to copy the MetaHost.h file to a location already on the Include search path, such as in your project’s directory.
Indeed, I’ve used MetaHost in several samples for starting the CLR using .Net from C++, and profiling CLR performance. See this link
Please sign in to use this experience.
Sign in