VS2019 Publishing Error : Load an assembly in an incorrect format (Microsoft.CSharp.dll)

Fiq 26 Reputation points
2021-08-18T07:55:21.193+00:00

I got an error when try to publish a .net library project. Try to troubleshoot it all night but not work. Search in Google and forum but nothing come out. Publish target-runtime is Portable (publish error occur). Change to win-x86 (same error occur).

Environment Info
MS Win 10 x86
MS VSC 2019 v16.11.1
.Net 5.0

Image 1 : Error
124211-err1.png

Image 2 : Output Log
124190-err2.png

Diagnostic Log

8/18/2021 3:11:41 PM
System.AggregateException: One or more errors occurred. ---> >Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were >unable to determine the cause of the error. Check the output log for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has >encountered an error. We were unable to determine the cause of the error. Check the output log for >more details. <---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were >unable to determine the cause of the error. Check the output log for more details.

===================

Any idea, help or solution to this problem is really appreaciate and thanks.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,218 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Fiq 26 Reputation points
    2021-08-18T10:49:03.01+00:00

    Finally, found the answer at GitHub.
    https://github.com/dotnet/core/issues/2716

    1. Open project Properties.
    2. Select Build tab.
    3. Go to Output section.
    4. Set Generate Serialization Assembly to Auto or Off

  2. Efim Zabarsky 1 Reputation point
    2022-04-06T06:20:49.197+00:00

    Hi,
    Put attention to versions of App Functions and version in Visual Studio

    Image:
    https://imgur.com/a/FAMsmsf


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.