Question

Error while compiling view

Error compiling template: views/devices.cshtml

Errors:
    [CS0234] Line: 3 Column: 27 - The type or namespace name 'Services' does 
    not exist in the namespace 'Rioxo.Companion' 
    (are you missing an assembly reference?)

Details:
@using System
@using System.Collections.Generic
@using Rioxo.Companion.Services <---

web.config

<razor disableAutoIncludeModelNamespace="false">
    <assemblies>
        <add assembly="Server32" />
        <add assembly="Rioxo.Companion.Services" />
    </assemblies>
    <namespaces>
        <add namespace="Rioxo.Companion.Server" />
        <add namespace="Rioxo.Companion.Services" />
    </namespaces>
</razor>

What could be the problem here?

Was it helpful?

Solution

Edit: the original problem was solved by putting the configuration in the correct .config file, for future reference, adding here you can also implement your own IRazorConfiguration which Nancy will automatically pick up, this means you don't need any .config registraion at all.

Example:

public class RazorConfig : IRazorConfiguration
{
    public IEnumerable<string> GetAssemblyNames()
    {
        yield return "MyWebsite.Web";
        yield return "MyWebsite.Models";
        yield return "Sandra.SimpleValidator";
        yield return "ServiceStack.Text";
    }

    public IEnumerable<string> GetDefaultNamespaces()
    {
        yield return "Nancy.Validation";
        yield return "System.Globalization";
        yield return "System.Collections.Generic";
        yield return "System.Linq";
        yield return "MyWebsite.Web";
        yield return "MyWebsite.Models";
        yield return "MyWebsite.Web.ViewModels";
        yield return "MyWebsite.Web.Helpers.RazorHelpers";
    }

    public bool AutoIncludeModelNamespace
    {
        get { return true; }
    }
}

Original Answer:

I don't actually know what Rioxo is and their site doesn't seem to have a download.

So I'm taking a shot here and assuming its because you haven't referenced the assembly by its name properly.

I think the name is probably Rioxo.Companion or Rioxo

So updating the <assemblies> section to something like:

<razor disableAutoIncludeModelNamespace="false">
    <assemblies>
        <add assembly="Server32" />
        <add assembly="Rioxo" />
    </assemblies>
    <namespaces>
        <add namespace="Rioxo.Companion.Server" />
        <add namespace="Rioxo.Companion.Services" />
    </namespaces>
</razor>

or

<razor disableAutoIncludeModelNamespace="false">
    <assemblies>
        <add assembly="Server32" />
        <add assembly="Rioxo.Companion" />
    </assemblies>
    <namespaces>
        <add namespace="Rioxo.Companion.Server" />
        <add namespace="Rioxo.Companion.Services" />
    </namespaces>
</razor>

Should fix the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top