I have the same error using visual studio 2022 and UE5, but I presume the Code Editor does not matter here.
It is true that with UE 4.27 I was able to compile from VS, even with Unreal editor open.
no compile error or warning
Then with UE5, I realized:
Both Code Editor and UE use yourProjectName\Binaries\Win64\UnrealEditor-yourProjectName.dll.
In fact even if I was able to compile, sometime I had Unreal editor 4.27 crashes, but I did not know why. Now it is clear. VS changes/updates/modifies this .dll that is used by Unreal Editor.
The only solution I suggest is :
- if you have to change header file (.h) close Unreal Editor, compile from your Code Editor then open unreal editor again.
- if you have to change .cpp files go on with Live Coding.
Live Coding replaces hot reload, So you should use live coding
Cheers