EPiCode Extensions and ambiguous reference

Posted on July 28, 2010 by Frederik Vig in EPiServer

On new projects where I use EPiCode Extensions I always register the namespace EPiCode.Extensions in my web.config – that way I can use the extension methods in my .aspx and .ascx files without needing to register EPiCode Extensions in every file.

...
      <namespaces>
        ...
        <add namespace="EPiCode.Extensions" />     
      </namespaces>
    </pages>
...

Sometimes this can cause some problems when you have other extension methods with the same method signature.

Ambiguous call between two extension methods with the same signature

In this case it was with EPiServer Composer. To fix it I created a simple web.config file that I placed inside the Dropit\Plugin\Extension folder.

Here’s the code.

<?xml version="1.0"?>
<configuration>
  <system.web>
      <pages>
          <namespaces>
              <remove namespace="EPiCode.Extensions" />
          </namespaces>
      </pages>
  </system.web>
</configuration>

You can also use the location element of your main web.config file instead.

<location path="dropit">
        <system.web>
            <pages>
                <namespaces>
                    <remove namespace="EPiCode.Extensions" />
                </namespaces>
            </pages>
        </system.web>
    </location>

And that’s it! This will also work for all the sub directories as well.

On a side-note: I’ve been adding a lot of new extension methods lately to the project. I’ve listed them on the project’s wiki-page. Go check them out!

Related Posts: