I've tested my code with ASP.NET MVC 3 3.0.20105.1 and it works. I want to upgrade to MVC 4 4.0.40804 but this snippet does not work. Even tried with MVC 5.2.2.
Tested with RazorGenerator 2.2.3
This is some simplified example-code from a helper.cshtml:
```
@using System
@* Generator: MvcHelper *@
@functions
{
public HelperResult Message(string msg)
{
return MessageHtml(msg);
}
}
@helper MessageHtml(string msg)
{
<h1>@msg</h1>
<h1 class="@msg">@msg</h1>
}
```
Then I use it in Index.cshtml:
```
@{
var h = new MvcApplication1.Helpers.Helper();
}
@h.Message("hello")
```
The first h1 will work but the other one wont (because of the class-attribute). I need to be able to create functions and reuseable helpers within one cshtml-file.
I get a basic null-reference error ("Object reference not set to an instance of an object").
Suggestions?
Comments: What's at line 14 of Helper.cshtml? Can you debug it to see if everything looks normal? Also, are you sure that the issue doesn't happen if you don't precompile your view?
Tested with RazorGenerator 2.2.3
This is some simplified example-code from a helper.cshtml:
```
@using System
@* Generator: MvcHelper *@
@functions
{
public HelperResult Message(string msg)
{
return MessageHtml(msg);
}
}
@helper MessageHtml(string msg)
{
<h1>@msg</h1>
<h1 class="@msg">@msg</h1>
}
```
Then I use it in Index.cshtml:
```
@{
var h = new MvcApplication1.Helpers.Helper();
}
@h.Message("hello")
```
The first h1 will work but the other one wont (because of the class-attribute). I need to be able to create functions and reuseable helpers within one cshtml-file.
I get a basic null-reference error ("Object reference not set to an instance of an object").
Suggestions?
Comments: What's at line 14 of Helper.cshtml? Can you debug it to see if everything looks normal? Also, are you sure that the issue doesn't happen if you don't precompile your view?