How get the default namespace of project csproj (VS 2008)

前端 未结 5 1578
终归单人心
终归单人心 2020-12-20 14:05

I have VS 2008 and csproj project (C# Library).

In properties of project, has an assembly name, and default namespace. Note: each class has a namespace.

Is

5条回答
  •  一整个雨季
    2020-12-20 14:44

    You can't.

    The default namespace isn't stored anywhere within the assembly. It's just a project setting of Visual Studio.

    What I tend to do is use the name of the assembly: Assembly.GetName().Name. The problem with this is that it only works if the assembly name has not been changed.

    For your specific issue, you can use assembly.GetManifestResourceNames() and do some tests over those names, e.g.:

    string name = assembly.GetManifestResourceNames().Single(p => p.EndsWith(".SyntaxModes.Xml"))
    

提交回复
热议问题