question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI: namespace error on fresh VB project

See original GitHub issue

@jcouv commented on Fri Sep 22 2017

Repro:

  1. mkdir 22227-cli-vb
  2. cd 22227-cli-vb
  3. dotnet new console --language=vb
  4. dotnet build produces the namespace error below
> dotnet --version
2.0.2-vspre-006949
> dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

vbc : error BC30113: '22227-cli-vb' is not a valid name and cannot be used as the root namespace name. [D:\issues\22227-cli-vb\22227-cli-vb.vbproj]

Build FAILED.

vbc : error BC30113: '22227-cli-vb' is not a valid name and cannot be used as the root namespace name. [D:\issues\22227-cli-vb\22227-cli-vb.vbproj]
    0 Warning(s)
    1 Error(s)

Relates to https://github.com/dotnet/roslyn/issues/22227


@am11 commented on Fri Sep 22 2017

Does vb.exe by design considers the directory name to be the root namespace unless we explicitly add normalized name in <RootNamespace>_22227_cli_vb</RootNamespace> in vbproj?

csc doesn’t seem to rely on dirname, even when there is no namespace in the program.cs code, actual dirname has invalid (hyphen) character and <RootNamespace> is set to 22227-cli-vb (with same invalid chars) in csproj.

If it’s not a breaking change, would be cool if vb.exe and csc.exe behave the same way.


@jcouv commented on Fri Sep 22 2017

It looks like the problem is not with vbc.exe, but with the arguments it receives. If the vbproj file is named A, then there is a /rootnamespace:A command-line option.

I’ll move the issue to the CLI repo.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
am11commented, Sep 22, 2017

C# doesn’t have the feature of a root namespace

That’s right. One thing I noticed that if we do something like:

dotnet new console -n 123-console
cat 123-console/Program.cs

It shows that namespace is set to sanitized dirname:

namespace _123_console
{
  .. ..
}

possible solutions

Could the same normalization be reused for VB root NS when setting the compiler arg in CLI?

0reactions
jmarolfcommented, Nov 14, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix a "type or namespace name could not be ...
The solution in this case is to either upgrade the framework target of the application (Project A), or downgrade the target of referenced ......
Read more >
Compiler Error CS0246
A type or namespace that is used in the program was not found. You might have forgotten to reference (References) the assembly that...
Read more >
C# the type or namespace name could not be found (are ...
The problem is that it can't find the class - it's not in the same namespace as your current code. That may be...
Read more >
VB Projects cannot be built when using the Global Namespace.
Description. VB Projects cannot be built due to the usage of the Global Namespace. Error Messages. Typical errors received on build are: Type...
Read more >
Implicit Using Statements In .NET 6 - NET Core Tutorials
I feel like a simpler idea would have been to edit the Visual Studio/Command Line templates that when you create a new web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found