Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Problem when use EmbeddedResources #2611


User avatar
0
goldstar25 created

I has use EmbeddedResources in .NET Core project. I found these following bug: 1._ViewImports.cshtml does not work 2. Can't use AreaAttribute. For the first point, My plus project's project.json is:

"buildOptions": {
    "embed": {
      "include": [
        "Views/*.*",
        "Views/**/*.*",
        "Localization/*.xml"
      ]
    }
  }

And error is: The name 'MetronicConsts' does not exist in the current context attachment is compilation source. And the _ViewImports.cshtml content is: @using Magicodes.Theme.Metronic @using Abp.Localization @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    First of all, "Views/**/." already contains "Views/.". So, no need to write "Views/.". As I understand, you are trying to separate some controllers and views into a different dll (maybe you are creating a plugin). However, you are trying to access a class named MetronicConsts. I suppose you added this class since AspNet Zero does not have such a class. So, is that class inside your plugin or did you add reference for it?

  • User Avatar
    0
    goldstar25 created

    I thought "Views/**/." may be not contains "_ViewImports.cshtml" and "_ViewStart.cshtml",so I have a try,but it also not work. If I add these code in view :

    @using Magicodes.Theme.Metronic
    

    It's OK. So I mean the "_ViewImports.cshtml" is not work. And the other problem is "Can't use AreaAttribute in plus Controllers",it's will not found view.

  • User Avatar
    0
    goldstar25 created

    I just tested,I found "_ViewStart.cshtml" also not work.

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    It's hard to understand the problem without checking your code. If you mean visual studio can not find class AreaAttribute by "Can't use AreaAttribute in plus Controllers", then you may not added related nuget packages to your plugin project.

    So, I can not help with these information. What we can do is that: you can either send your project to <a href="mailto:[email protected]">[email protected]</a> or we can arrange a teamviewer meeting to see what you've done. What do you prefer? Please write to <a href="mailto:[email protected]">[email protected]</a>.