roslyn: Hot Reload unusable with CS8055 if a file created via "Move type to X.cs" is not touched by the user

Version Used

VS 2022 Version 17.9.5 Roslyn 4.9.0 (a98c90d5645537)

Project info C# 12.0 .NET 8.0

Steps to Reproduce

  1. Create a file XYZ.cs that contains a type named XYZ
  2. Within that same file declare another type named ABC (different than XYZ)
  3. Use the “Move type to ABC.cs” code action
  4. Run the program with a debugger
  5. Pause execution at any point
  6. Edit any file within the assembly containing the above types (XYZ and ABC)
  7. Ensure that there are no compiler errors after the edits
  8. Use Hot Reload to load the changes onto the program and continue execution

Expected Behavior

Hot Reload works as expected, without any errors.

Actual Behavior

Hot Reload fails, and the following is observed in the output of Hot Reload:

19:44 51.27 [Error] E:\repos\[truncated]\File.cs (line 1): error CS8055: Cannot emit debug information for a source text without encoding.
19:44 51.27 Invalid changes were found. Please refer to the Error List window to fix those issues.

The user is prompted to edit the code or rerun the program anew, after Hot Reload fails.

The bug can be worked around by manually changing and saving changes to the ABC file before hot reloading, without stopping the current execution. Once the file is manually changed, hot reloading works.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I request that this issue be reopened. I have this every single time. Tried deleting vs folders, reopening, regenerating. Nothing fixes it. And for me, none of the proposed fixes or workarounds work. I’m not even 100% sure whether the trigger is the same. I just know that once this starts happening, it can’t be (and has not been) stopped. It makes work much more painful

That bug is a hell. I do have it every single time by changing any line of code. I restart visual studio, it then works for some very few hot reload then the problem appear again. Once it appear, no way…

Any updates on this?

When an release for this fix will be available? Still getting same problem even with latest VS and .NET 9

error CS8055: Cannot emit debug information for a source text without encoding.

Now even worse, even closing/reopening VS don’t have any effect, unable to use hot reloading in razor pages, need to restart entire server even for minimal fixes.

PRs always welcome. Help wanted is more like: better odds of this happening if you just do it 😃

Still not fix yet?

I’ve run into this so many times, probably because I have a tendency to add types wherever I feel like it and then use the move to separate file action later on. Thanks @Rekkonnect for the bug report & workaround!

This issue started to happen a few weeks ago… I was never aware it even existed, but now the latest VS is triggering this error all the time…

I see this as well in Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.13.2. Very annoying when just having moved a bunch of files with automatic namespace change.

Hello! I’m now using lastest preview version of VS2022 (17.14.0-pre.1.1+35821.62) and this problem still persist.

Image

14:18 45.41 XmppServer (12): Hot Reload session started.
14:19 13.36 [Error] Project C:\Projects\WarfaceClub\XmppServer\XmppServer.csproj ({0E4C8091-A387-45CF-B13A-8EAD4864318C}) update error: C:\Projects\WarfaceClub\XmppServer\Entities\XmppAccountType.cs(1,1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.37 [Error] Project C:\Projects\WarfaceClub\XmppServer\XmppServer.csproj ({0E4C8091-A387-45CF-B13A-8EAD4864318C}) update error: C:\Projects\WarfaceClub\XmppServer\Net\XmppServerType.cs(1,1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.37 [Error] Project C:\Projects\WarfaceClub\XmppServer\XmppServer.csproj ({0E4C8091-A387-45CF-B13A-8EAD4864318C}) update error: C:\Projects\WarfaceClub\XmppServer\Services\XmppServerManager.cs(1,1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.50 XmppServer (12): [Error] C:\Projects\WarfaceClub\XmppServer\obj\Debug\net9.0\.NETCoreApp,Version=v9.0.AssemblyAttributes.cs(1,6,1,12): The using directive for 'System' appeared previously as global using
14:19 13.50 XmppServer (12): [Error] C:\Projects\WarfaceClub\XmppServer\obj\Debug\net9.0\XmppServer.AssemblyInfo.cs(10,6,10,12): The using directive for 'System' appeared previously as global using
14:19 13.50 XmppServer (12): [Error] Errors found in application: 
14:19 13.50 XmppServer (12): [Error] C:\Projects\WarfaceClub\XmppServer\Entities\XmppAccountType.cs(0,0,7,0): Cannot emit debug information for a source text without encoding.
14:19 13.50 XmppServer (12): [Error] C:\Projects\WarfaceClub\XmppServer\Net\XmppServerType.cs(0,0,8,0): Cannot emit debug information for a source text without encoding.
14:19 13.50 XmppServer (12): [Error] C:\Projects\WarfaceClub\XmppServer\Services\XmppServerManager.cs(0,0,51,1): Cannot emit debug information for a source text without encoding.
14:19 13.50 [Error] C:\Projects\WarfaceClub\XmppServer\Entities\XmppAccountType.cs (line 1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.50 [Error] C:\Projects\WarfaceClub\XmppServer\Net\XmppServerType.cs (line 1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.50 [Error] C:\Projects\WarfaceClub\XmppServer\Services\XmppServerManager.cs (line 1): error CS8055: Cannot emit debug information for a source text without encoding.
14:19 13.54 Invalid changes were found. Please refer to the Error List window to fix those issues.

When i open the “problematic” file:

Image

Same steps, declare any type in file MyType.cs, move type to AnotherType.cs (sometimes moving type to other file fails and i need to do this multiple times untill works)

I must restart entire VS2022 to “fix” these errors.

Thanks for the info. Oh okay, I thought it was already in the release channel, its in preview.

@nathan130200 the linked pr days it went into 17.13p3

Any updates on this? I hit this issue constantly on Visual Studio