ASPNETCOMPILER error ASPCONFIG: Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies

For me it was indeed an x86/x64 mismatch. I solved it by specifying the path to the x64 MSBuild through the MSBuild environment variable:

Set the MSBuild environment variable


This error had to do with class libraries in the solution referencing older (v3 or v3.5) system assemblies. Those class libraries were referenced by my website, so the system assemblies got copied to the bin folder along with the class libraries. Maybe the system assemblies in the 3.5 directory have different permissions than the 4.0 directory and when the aspnet_compiler tried to load them from the bin directory, it barfed.

After going through each csproj file and updating <RequiredTargetFramework> values to 4.0, everything is working as expected.


I got the same error building the .csproj_deploy from VS. All other projects including the web in the solution built fine. There was actually this Microsoft.VisualBasic.Activities.Compiler dll in my web bin folder. When I clicked build/clean solution, all the files in the folder got deleted except this. I manually deleted this file and built again and it built fine. This time, I do not even see this file in the bin folder.