Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this with Visual Studio? #74

Closed
sbond75 opened this issue Mar 23, 2023 · 4 comments
Closed

How to use this with Visual Studio? #74

sbond75 opened this issue Mar 23, 2023 · 4 comments

Comments

@sbond75
Copy link

sbond75 commented Mar 23, 2023

Hello,

I have seen this tip but I have a solution file in Visual Studio and can use the IDE itself or msbuild to compile my project from the command-line. In my solution file I have a project that produces a DLL that cr.h is managing as the "guest application", and the "host" is an executable that is being debugged by Visual Studio. It would be ideal to be able to recompile the DLL while the host program is running in the debugger. I have tried externally invoking msbuild while it runs but it says the PDB file is locked. Apparently this is a common issue with hot reloading. Is this not the intended setup, or is there something I'm missing?

@fungos
Copy link
Owner

fungos commented Mar 24, 2023

That is supposed to work, as cr was created to solve the dll lock issue. Debugging the host should not lock the plug-in in any way, not sure what may be happening on your case. Try to validate that the plug-in is actually being copied and versioned in the output folder.

@sbond75
Copy link
Author

sbond75 commented Mar 24, 2023

I saw that the plugin was copied in the output folder with a "1" appended. What is the copy of the DLL used for? I would imagine it would be better to unload the DLL, invoke the compiler, then reload the DLL?

@fungos
Copy link
Owner

fungos commented Mar 25, 2023

cr host will monitor any timestamp change on the original dll, once detected it will unload the current loaded which is a copy that cr host does before loading one dll, and so it will copy this dll over and append a number which is used to track live rollback. Which this, the host will never lock the original dll compiled as it never uses that but only a copy. There are some details though though, just the copy will not actually guarantee the original dll isn't locked as cr needs to patch some debug info inside the copied dll.
in your case, you may have a problem there, where cr is unable to patch this data for some reason (path invalid? too long?), best would be to enable cr tracing and debug the cr host loading the dll.

@sbond75
Copy link
Author

sbond75 commented Mar 26, 2023

I found that I needed to link against the DLL from the host with /DELAY:UNLOAD and /DELAYLOAD: with the dll name appended, following this MSVC feature. However, I have not tested it with cr.h and am now using this for hot reload. If I need to switch back to it, it would probably work fine since this also seems to fix the pdb lock.

@sbond75 sbond75 closed this as completed Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants