Share via


MSB4062: The task could not be loaded from the assembly

This error is emitted when a task assembly cannot be loaded prior to executing a task.

Error MSB4018 may be caused when running a task in an environment that it was not prepared for, for instance when a task assembly targets 32-bit x86 but is running in a 64-bit MSBuild environment.

S:\BitnessInMSBuild\ShowErrors.proj(13,5): error MSB4062: The "TaskCompiledForx86" task could not be loaded from the assembly S:\BitnessInMSBuild\TaskCompiledForx86\bin\Debug\net472\TaskCompiledForx86.dll. Could not load file or assembly 'file:///S:\BitnessInMSBuild\TaskCompiledForx86\bin\Debug\net472\TaskCompiledForx86.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

To resolve this, ensure that the task expresses a dependency on the runtime environment it requires in the task's UsingTask element.