[RESOLVED]Difficulties debugging a cshtml partial view.

I have a razor block in an html view with the following lines in it:

List<KeyValuePair<string, string>> TheList = new List<KeyValuePair<string, string>>();
TheList.Add(new KeyValuePair<string, string>("0", BusinessFramework.TemplateScope.NotShared.ToString()));

Now if I change the second line above to read like this:

TheList.Add(new KeyValuePair<string, string>(0, BusinessFramework.TemplateScope.NotShared.ToString()));

The compiler does not show any errors, but when I try to run the debugger and navigate to this view, I get "Unable to load: Status 500".  If I try to set a breakpoint in the view, when I run the debugger it says it can’t hit the line of code since no symbols
have been loaded.

OK, so I got passed that bug, but now I have a new one further down the page on this line of code:

if (Model.TheFeature.Publishing != null) { scope = Model.TheFeature.Publishing.Scope; }

My point in all of this is… Do I have something set wrong in vs2012?  Why is it not giving my any information as to what is wrong with the code?  It’s apparent there are compile errors, but why do I have to go through trial and error to figure out what’s
going on?  Why can’t I step through the razor view code and see what’s wrong?  If there’s a compile error, why won’t VS tell me about it?

I forget sometimes that this is still windows – a reboot fixed the issue.  And here I was thinking I had done something to confuse the debugger or compiler.  :)

Hi dolot,

For the other way, you may try to clean your solution and rebuild it.

Best Regards


‘clean the solution’?  Is that a function in VS?

Leave a Reply