I have found that Edit-and-Continue does not work in linked files. I am working on a suite of 8 different utilities (C# winforms) and they all share several common classes, which have been added to each utility project as a linked file. I can set breakpoints in the linked files, and step thru the code in them, but not edit. When I try, I get the error "Changes are not allowed if the project wasn't built when debugging started." I've made sure to perform a clean and build before running, but that doesn't help. I've had some of my colleagues try it on their machines with the same results. These linked common classes are key to each of the utilities and where much of the code resides. Not being able to edit-and-continue is making debugging much more difficult and tedious. Edit and continue works in the non-linked non-common files. Can anyone suggest a workaround? I have considered merging all 8 utilities into one, but they each take different command line parameters and are really intended to be used individually.
Asked
Active
Viewed 148 times
0
-
"linked files" doesn't mean much, C# does not use a linker. If you added a reference to these assemblies with the Browse button then, sure, E+C isn't going to work. It needs the project file of the assembly to know how to recompile the code correctly. Just add the project file(s) to your solution. – Hans Passant Oct 07 '17 at 15:19
-
Each of the 8 utilities projects is in it's own folder. The common/shared classes are also in their own folder. The shared classes are added by doing Add->Existing Item->Pick the files->Change drop down on Add button to Add As Link. If I don't add as a link, it copies the common files to the folder of that utility, and I end up with 8 different copies. I'm not sure what you mean by add the assembly, because the common files are just source code of classes, they are not compiled into a DLL or component. Each utility has an assembly, but the common shared code does not. – DrWizard Oct 07 '17 at 22:59
-
Why are you doing these strange and painful things? 8 copies?? https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Hans Passant Oct 07 '17 at 23:08
-
Nooooo, I want to avoid 8 copies! I have 8 different utility programs as part of a suite. Each does something different. (FYI: For editing Light-O-Rama sequences). But all of the 8 utils uses a subset of the same code. The common code code is in a "Common" folder, and the 8 utils in their own folders. The code in the common folder is included in each project, but as a link. If you do not choose 'as a link' when adding, it makes a separate copy in each project folder. – DrWizard Oct 08 '17 at 00:31
-
But when it is 'as a link' I cannot edit and continue in those shared files. I can set breakpoints, and step thru it, but not edit and continue. I have to stop it to edit those files. (I can edit and continue in the non-shared files OK). – DrWizard Oct 08 '17 at 00:31
-
See these solutions: https://stackoverflow.com/questions/9219555/make-reference-to-c-sharp-code-from-multiple-projects https://stackoverflow.com/questions/2666898/share-c-sharp-class-source-code-between-several-projects https://stackoverflow.com/questions/1116465/how-do-you-share-code-between-projects-solutions-in-visual-studio https://stackoverflow.com/questions/4336525/sharing-code-between-2-projects-without-a-dll https://stackoverflow.com/questions/4345780/how-do-i-keep-common-code-shared-between-projects-in-c – DrWizard Oct 08 '17 at 00:47