{"action":"closed","issue":{"url":"https://api.github.com/repos/Antaris/RazorEngine/issues/237","labels_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/237/comments","events_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/237/events","html_url":"https://github.com/Antaris/RazorEngine/issues/237","id":57162803,"number":237,"title":"RunCompile fails if there is no model but there is a ViewBag","user":{"login":"PhilipDaniels","id":1809220,"avatar_url":"https://avatars.githubusercontent.com/u/1809220?v=3","gravatar_id":"","url":"https://api.github.com/users/PhilipDaniels","html_url":"https://github.com/PhilipDaniels","followers_url":"https://api.github.com/users/PhilipDaniels/followers","following_url":"https://api.github.com/users/PhilipDaniels/following{/other_user}","gists_url":"https://api.github.com/users/PhilipDaniels/gists{/gist_id}","starred_url":"https://api.github.com/users/PhilipDaniels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhilipDaniels/subscriptions","organizations_url":"https://api.github.com/users/PhilipDaniels/orgs","repos_url":"https://api.github.com/users/PhilipDaniels/repos","events_url":"https://api.github.com/users/PhilipDaniels/events{/privacy}","received_events_url":"https://api.github.com/users/PhilipDaniels/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Antaris/RazorEngine/labels/need-info","name":"need-info","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-10T11:30:47Z","updated_at":"2015-02-10T13:05:00Z","closed_at":"2015-02-10T13:05:00Z","body":"I have this line of code in my app\r\n\r\n    dynamic vb = new DynamicViewBag();\r\n    // add stuff to vb...\r\n    razorEngineService.RunCompile(file.Contents, file.Filename, null, (DynamicViewBag)vb);\r\n\r\nI call this when there is no @Model directive in the page. This used to work fine when vb was always null, but now I have started to create viewbags. The above line of code will fail when vb is non-null, with a RuntimeBinderException \"Cannot perform runtime binding on a null reference\".\r\n\r\nIt can be fixed by adding an (unused and pointless) \"@model\" directive to the cshtml file, or by injecting an empty model - this doesn't throw:\r\n\r\n    var model = new object();\r\n    razorEngineService.RunCompile(file.Contents, file.Filename, model.GetType(), model, (DynamicViewBag)vb);\r\n\r\nbut I don't think the first call should fail either. I have RazorEngine 3.5.2.\r\n"}}