Aspnetcore: CS0103 C# The name 'context' does not exist in the current context

Created on 22 Apr 2019  路  5Comments  路  Source: dotnet/aspnetcore

Visual Studio 2019 does not see part of the component when using using

To Reproduce

1) Create a component in a different folder.
2) Connect it anywhere using using
3) Error "CS0103 C # The name 'context' doesn鈥檛 exist in the current context"

Screenshots

http://dt-byte.ru/fcb6801d.png

Additional context

dotnet --info
袩邪泻械褌 SDK 写谢褟 .NET Core (芯褌褉邪卸邪褞褖懈泄 谢褞斜芯泄 global.json):
 Version:   3.0.100-preview4-011223
 Commit:    118dd862c8

小褉械写邪 胁褘锌芯谢薪械薪懈褟:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview4-011223\

Host (useful for support):
  Version: 3.0.0-preview4-27615-11
  Commit:  ee54d4cbd2

Components/TableView.razor

@typeparam TItem

@for (var i = 0; i < Items.Count; i++)
{
    <p>@Body(Items[i])</p>
}

@functions{
    [Parameter]
    IReadOnlyList<TItem> Items { get; set; }

    [Parameter]
    protected RenderFragment<TItem> Body { get; set; }
}

Pages/index.razor

@page "/"
@using Blazorside.Components

<TableView Items="@Items">
    <Body>
        @context
    </Body>
</TableView>

@functions{
    List<string> Items { get; set; } = new List<string> { "one", "two" };
}

For clarity, I鈥檒l clarify that the error occurs only in Visual Studio and only if TableView.razor is in a different folder, the project itself is being built and working.

area-blazor

Most helpful comment

If the project builds successfully on the command-line, then this looks like a known tooling limitation with VS2019 16.1 Preview 1, which will get fixed shortly with Preview 2. To workaround the tooling issue you should be able to fully qualify the component tag name with the component's namespace.

All 5 comments

This is also happening with the Telerik UI for Blazor grid templates. We are also seeing customers report that context does not exist.

https://twitter.com/robertmclaws/status/1117927153356673024

image

https://github.com/BarnyardTech/dgTelerikTest

If the project builds successfully on the command-line, then this looks like a known tooling limitation with VS2019 16.1 Preview 1, which will get fixed shortly with Preview 2. To workaround the tooling issue you should be able to fully qualify the component tag name with the component's namespace.

May be related - when in a subfolder (like ~/Shared/someFolder/myComponent.razor), the components' intellisense does not recognize the [Parameter] attribute, but it does compile and work.

parameter-not-recognized-fixed-color

Edit: fixed screenshot

This should be fixed now with Visual Studio 2019 16.1 Preview 2. Install the latest bits from the Visual Studio 2019 Preview channel and you should be good to go. Let us know if this doesn't resolve the issue for you!

Thanks, it works

Was this page helpful?
0 / 5 - 0 ratings