Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taghelper: Cannot resolve TagHelper containing assembly

I cannot get a custom TagHelper to work in my ASP.NET v5 project. The custom TagHelper is located in the web project itself. I tried following this sample this sample from CodeProject and this tutorial too.

When I try to use the tag without addTagHelper: nothing is transformed, no breakpoints hit in the tag helper.

When I try to @addTagHelper "*, MyWebApplication" to the Viewcomponent, the error is MyWebApplication'. Error: Could not load file or assembly 'MyWebApplication'.

What am I missing?

Tool versions:

Microsoft Visual Studio Enterprise 2015 RC
Version 14.0.22823.1 D14REL
Microsoft .NET Framework Version 4.6.00057
Microsoft.AspNet.Mvc 6.0.0-beta4
like image 317
fiat Avatar asked Mar 16 '23 12:03

fiat


1 Answers

The advertised signature for addTagHelper is

@addTagHelper "className/Filter", "assemblyName"

Behaviour actually appears to be (at least for helpers in same web project)

addTagHelper "className/Filter", "folderName"

because at least into Beta6, the assembly name is the folder name and ignores the attributes in the project properties.

Here is a sample working demo

  1. Hit F5, view cats.
  2. Edit the project properties to change the assembly name.
  3. Hit F5, view cats. << This should not work?!
  4. Close solution, rename the on disk directory TagHelperDemo -> TagHelperFolderDemo
  5. Observe page fails until the folder name is used for addTagHelper directive

PS: @addTagHelper is required even when the TagHelper is in the same project. VS2015 re-colours the tag as purple when it is targeted by a TagHelper.

like image 84
fiat Avatar answered Mar 25 '23 00:03

fiat