vb.net - Extension method not being recognized -


i've got web application project in vb.net , trying add extension method use in in view.

extensions.vb

imports system.runtime.compilerservices     namespace myapp     public module extensions         <extension()> _             public function getvalordefault(byval dict dictionary(of string, string), byval key string, byval defaultval string) string                     dim val string                     if (dict.trygetvalue(key, val))                         return val                     end if                 return defaultval             end function         end module end namespace 

view.cshtml

@code     dim msgs dictionary(of string, string) = new dictionary(of string, string)     msgs("foo") = "bar"     dim val string = msgs.getvalordefault("foo", "bar") end code 

however, doesn't work, showing following error:

'getvalordefault' not member of 'system.collections.generic.dictionary(of string, string)'. 

this straightforward extension method, , i'm not sure why it's not being picked up. tried adding simpler extension taking string , returning string, same problem, seems extension methods aren't being picked up.

tried compiling, no luck. note, module in same project view, don't think should make difference (i've done in c# projects no problems).

is there step or else i'm missing needs done work?

it's old question, but, in case others scratching heads, make sure check build action of file containing extension set compile. after 2 hours of going quietly insane , wondering why extension worked in places, realised set content. quick change compile , worked. :)


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -