0

I'm working on an ASP.NET Web Forms application (.NET Framework 4.7.2) and I'm trying to build the solution with MSBuild.

msbuild Project.sln /p:Configuration=Release /p:Platform="Any CPU"

However, I'm getting the following error:

error CS0433: The type 'includes_controls_GridFilter' exists in both 'App_Web_5ozmheie, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' and 'App_Web_e2c40wid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' [D:\Source\Repos\X\X.metaproj]

The strange thing is that the solution builds fine in Visual Studio, so I'm not sure what's causing this error.

I've tried checking the project references and clearing the ASP.NET temporary files, but the error still persists. Does anyone have any suggestions on how to resolve this issue?

Any help would be greatly appreciated!

Mehran Hafizi
  • 2,392
  • 2
  • 12
  • 14
  • If you're trying to build it with MSBuild, what command are you using to build it? Have you tried cleaning out the bin and obj folders? – mason Feb 21 '23 at 16:42
  • THis is the command I used : msbuild Project.sln /p:Configuration=Release /p:Platform="Any CPU" Yes,I've deleted those foldres as well – Mehran Hafizi Feb 21 '23 at 17:20
  • You probably deleted the wrong folders. Enable MSBuild bin log https://msbuildlog.com/ and see where exactly is being checked by MSBuild. – Lex Li Feb 22 '23 at 04:15

1 Answers1

0

From you error message, It seems like the type includes_controls_GridFilter are both in App_Web_5ozmheie and App_Web_e2c40wid file .It’s not able to distinguish which one is referenced.

Based on the Compiler Error CS0433,I created 2 class file with the same namespace(TypeBindConflicts) and same class name(class1) for test and then reference class1 in another project. When I use msbuild command,I reproduced the same error CS0433.When i build in VS2022, The same error was generated.

Class1.cs

namespace TypeBindConflicts
{
    public class Class1
    {

    }
   
}

So I think If you reference a type with the same name from the same namespace, an error will be reported in both msbuild and VS. But I assume there's a difference in how the project is built in VS and in MSBuild. Visual Studio does not execute MSBuild.exe, but hosts the build engine itself.

Here’s a suggestion you can check:

1 For this Error CS0433, you check if there is same namespace or same name includes_controls_GridFilter in your App_Web_5ozmheie file and App_Web_e2c40wid file. Try to rename the type includes_controls_GridFilter to something else.

2 The strange thing is that the solution builds fine in Visual Studio but not with msubild.Just an idea, there may be something to do with the cache. Try to delete bin and obj folders, then do a clean/rebuild.

3 This ticket has a similar issue, you can try it by following it’s method and see if it works for you.

Hope these suggestions give you some ideas.I'm not sure if that will fully address your problem, though.

Dou Xu-MSFT
  • 880
  • 1
  • 1
  • 4