CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

Visual Studio Upgrade Issue for generating files

Open RahulSrivastava-dev opened this issue 3 years ago • 5 comments
trafficstars

Brief Description

There is Visual Studio 2019 version 16.6.5 or below dependency on cppsharp version 0.10.1. When I am upgrading to Visual Studio 2019 latest version (16.11.19), interop generator is not able to generate files. Error log is attached below. Please guide on how to resolve this issue since I am not able to find any suitable thread for this issue.

OS: Windows 10 version 21H2 (OS Build 19044-2006)

Used headers
Used settings

32 bit environment.

Target: MSVC/GCC/Clang MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.26) C++ ATL for latest v142 build tools (x86 & x64) C++ MFC for latest v142 build tools (x86 & x64) Windows 10 SDK latest available(currently on 10.0.19041.0)

Other settings

Stack trace or incompilable generated code

Parsing code... Error parsing 'Component.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'ExportOptions.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'JetFireExportInput.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'BleveCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'CascadeCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'DenseGasDispersionCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\DenseGasDispersion\DenseGasDispersionApi\DenseGasDispersionCalculator.h(9,10): fatal: 'string' file not found Error parsing 'ExplosionCamCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'ExplosionScopeCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels\ContourPlot.h(8,10): fatal: 'string' file not found Error parsing 'ExplosionTnoCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\ExplosionTno\ExplosionTnoApi\ExplosionTnoCalculator.h(2,10): fatal: 'string' file not found Error parsing 'GasJetFlameCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'GaussianDispersionCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\GaussianDispersion\GaussianDispersionApi\GaussianDispersionCalculator.h(2,10): fatal: 'string' file not found Error parsing 'HeatUpCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\HeatUp\HeatUpApi\HeatUpCalculator.h(2,10): fatal: 'string' file not found Error parsing 'PipeBlowdownCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\PipeBlowdown\PipeBlowdownApi\PipeBlowdownCalculator.h(2,10): fatal: 'string' file not found Error parsing 'PoolFireCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\PoolFire\PoolFireApi/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'PressureReliefValveCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\PressureReliefValve\PressureReliefValveApi\PressureReliefValveCalculator.h(3,10): fatal: 'string' file not found Error parsing 'PressurisedReleaseCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\PressurisedRelease\PressurisedReleaseApi/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'SmokeCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'Windows.h' file not found Parsed 'ChicFireSource.h' Parsed 'PoolFireFireSource.h' Parsed 'PressurisedReleaseFireSource.h' Error parsing 'TemperatureRiseCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\TemperatureRise\TemperatureRiseApi/CustomMaterial.h(2,10): fatal: 'string' file not found Error parsing 'TrenchFireCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\TrenchFire\TrenchFireApi/framework.h(5,10): fatal: 'Windows.h' file not found Error parsing 'TwoPhaseBlowdownCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\TwoPhaseBlowdown\TwoPhaseBlowdownApi\TwoPhaseBlowdownCalculator.h(2,10): fatal: 'string' file not found Error parsing 'UnifiedScenarioCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\UnifiedScenario\UnifiedScenarioApi\UnifiedScenarioCalculator.h(2,10): fatal: 'string' file not found Error parsing 'VesselBurstCalculator.h' C:\InteropGenerator\bin\x86\Debug\net46..........\VesselBurst\VesselBurstApi/framework.h(5,10): fatal: 'Windows.h' file not found CppSharp has encountered an error while parsing code.

C:\InteropGenerator\bin\x86\Debug\net46\Shell.MajorHazards.Science.InteropGenerator.exe (process 25820) exited with code -1. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .

RahulSrivastava-dev avatar Sep 20 '22 16:09 RahulSrivastava-dev

I'm a bit confused by this Rahul,

You seem to be using an old release and your folders say .NET 4.6 which we do not support anymore since we switched to .NET Core. Also the errors are about seemingly missing the Windows SDK headers, which could point to an issue with your VS setup.

Not sure how to help you fix this, but I would think about switching to .NET Core. You could try setting up a new working project and moving your generator over to that.

tritao avatar Sep 20 '22 17:09 tritao

Version 0.10.1 was used of cppsharp which was on .NET framework approx. 2 years back in my project. There is plan to migrate to .NET Core but I think there was significant change which was made in version 0.10.2 of cppsharp (and later) which is stopping me in upgrading the project. First I need to upgrade Visual Studio followed by cppsharp upgrade. When I use Visual Studio 2019 version 16.6.5 with SDK installed it compiles properly but as soon I put latest Visual Studio 2019 keep rest of the environment same then it start throwing error.

RahulSrivastava-dev avatar Sep 21 '22 03:09 RahulSrivastava-dev

'Windows.h' file not found indicates that either windows SDK is not installed or it is not finding the path to the SDK in the visual studio.

So make sure you have windows SDK installed and it is in the include path.

If windows SDK is already installed then try adding "SDK Path\Include" to: Project → Preferences → C/C++ → General → Additional Include Directories And add "SDK Path\Lib" to: Project → Preferences → Linker → General → Additional Library Directories

This should resolve 'Windows.h' not found.

nj-in-shell avatar Sep 21 '22 12:09 nj-in-shell

I tried the change suggested by @nj-in-shell but does not make any difference. When file is not getting compiled and when I go to framework.h file and press ctrl+left mouse click then it point to Windows.h file but when I compile it with cppsharp project it throws the error. A brief log is:

7>Error parsing 'Component.h' 7>C:\Users\Rahul.Srivastava\source\repos\Major-Hazards-FRED\Source\Science\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'windows.h' file not found 7>Error parsing 'ExportOptions.h' 7>C:\Users\Rahul.Srivastava\source\repos\Major-Hazards-FRED\Source\Science\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'windows.h' file not found 7>Error parsing 'JetFireExportInput.h' 7>C:\Users\Rahul.Srivastava\source\repos\Major-Hazards-FRED\Source\Science\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'windows.h' file not found 7>Error parsing 'BleveCalculator.h' 7>C:\Users\Rahul.Srivastava\source\repos\Major-Hazards-FRED\Source\Science\InteropGenerator\bin\x86\Debug\net46..........\Common\CommonDomainModels/framework.h(5,10): fatal: 'windows.h' file not found 7>CppSharp has encountered an error while parsing code.

RahulSrivastava-dev avatar Sep 21 '22 17:09 RahulSrivastava-dev

@RahulSrivastava-dev - This could happen if there are customized include/library paths in legacy projects.

If someone/you have added their/your own additional paths in project properties, VisualStudio 2019 can't automatically figure out base paths when switching between platforms/toolsets - usually it automatically puts correct paths there, but if you added customizations, VS wouldn't touch them.

Perhaps you can try following -

Install "Windows Universal CRT SDK" also in your visual studio application - which adds support for legacy Windows SDKs.

After setting the correct platform and toolset understood by VS2019 Open project properties, go to VC++ Directories, for 'Include Directories' and for 'Library Directories', choose "Inherit from parent or project defaults". This will remove your additional paths.

Click 'Apply'. This will reset include path to something like $(VC IncludePath x86);$(WindowsSdk XXX IncludePath_x86) (will vary for SDKs).

Re-add your extra paths here, or better yet - under C/C++/General -> Additional Include Directories and Linker/General -> Additional Library Directories.

Good luck

nj-in-shell avatar Sep 23 '22 10:09 nj-in-shell