Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Questo articolo descrive il codice di errore MSB4018.
Testo del messaggio
MSB4018: The 'value' task failed unexpectedly.
Descrizione
Questo errore viene generato quando un'attività non riesce con un'eccezione non gestita. Questo problema è in genere un segno di un bug nell'attività.
Questo errore può verificarsi quando la compilazione esegue un'attività in un ambiente per cui non è stata preparata. Ad esempio, quando un'attività ha una dipendenza x86, ma l'attività viene eseguita in un ambiente MSBuild a 64 bit. Questo scenario può manifestarsi come eccezione System.DllNotFoundException, come illustrato nell'output seguente.
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: The "AnyCPUTaskWithPInvoke" task failed unexpectedly.
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: System.DllNotFoundException: Unable to load DLL 'Native32BitLibrary.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: at AnyCPUTaskWithPInvoke.AnyCPUTaskWithPInvoke.NativeMethod()
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: at AnyCPUTaskWithPInvoke.AnyCPUTaskWithPInvoke.OtherMethod() in S:\BitnessInMSBuild\AnyCPUTaskWithPInvoke\AnyCPUTaskWithPInvoke.cs:line 19
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: at AnyCPUTaskWithPInvoke.AnyCPUTaskWithPInvoke.Execute() in S:\BitnessInMSBuild\AnyCPUTaskWithPInvoke\AnyCPUTaskWithPInvoke.cs:line 12
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
S:\BitnessInMSBuild\ShowErrors.proj(6,7): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Risoluzione
Assicurarsi che l'attività esprime una dipendenza dall'ambiente di runtime richiesto nell'elemento UsingTask dell'attività.
Si applica a:
Tutte le versioni di MSBuild