Reputation: 13
I have a personal project for school written in VB.NET. Before this, the framework I was using was .NET Framework 4.7. Then, I decided to upgrade it to .NET 8 because I need DPI awareness feature in it. But now I can't open any Form Designer with this error.
Type 'System.IO.MemoryStream' in Assembly 'System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not marked as serializable.
here's the call stack:
at StreamJsonRpc.JsonRpc.d_154'1.MoveNext( --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw( at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.DotNet.DesignTools.Client.Host.ServerHost.d_16.MoveNext( --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw( at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.DotNet.DesignTools.Client.DesignToolsClientLoader.d_29.MoveNext( --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.DotNet.DesignTools.Client.DesignToolsClientLoader .< >c_DisplayClass25_1 .<<- ctor>b_1>d.MoveNext( --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.DotNet.DesignTools.Client.DesignToolsClientLoader.d_27.MoveNext(
I've been doing some research before this. One workaround that I tried was moving all the project files (form, resources, etc.) from old solution to the new solution. It worked If I only moved some of the forms (the designer will load). But, when I moved all the forms, the same error pops up again. I clearly had no idea with this issue.
Any help will be really appreciated. Thank you!
Upvotes: 0
Views: 328
Reputation: 483
Some types, like MemoryStream, are not marked as Serializable
in .NET 8, which can break compatibility with components that expect serialization.
Inspect the error form for code that may implicitly require serialization, especially if they use non-serializable types like MemoryStream. Convert the MemoryStream to a byte array (using MemoryStream.ToArray() or MemoryStream.GetBuffer()). Then, pass this byte array instead of the MemoryStream itself.
Upvotes: 0