Edit

Share via


MSB4062

This article describes the MSB4062 error code.

Message text

MSB4062: The task could not be loaded from the assembly.

Description

This error is emitted when MSBuild can't load a task assembly before executing the task.

Error MSB4062 might be caused when a task runs in an environment for which it isn't prepared. For example, when a task assembly targets 32-bit x86 but it runs 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.

Resolution

Ensure the task expresses a dependency on the runtime environment it requires in the task's UsingTask element.

Applies to

All versions of MSBuild