Вопрос

I have a usercontrol (ascx) and want to use a namespace which i get with "import":

<%@ Import Namespace="my.assembly.blabla.bla.test" %>

The namespace definetly exists - it is used in code behind und the dll is referenced in the project. On run-time i get the error

The type or nemspace 'bla' does not exist in the namespace 'blabla' (are you missing an assembly reference?)

The strange thing is, when i add a register-directive (which i don't use), then it works. the register directive looks like this:

<%@ Register TagPrefix="xxx" Assembly="my.assembly.blabla,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=373h77ghg78hh478"
Namespace="my.assembly.blabla.bla" %>

I don't want to put everywhere an unused register-directive, so does anyone know what i'm doing wrong?

Это было полезно?

Решение

Add to web.config under configuration/system.web/compilation/assemblies:

<add assembly="my.assembly.blabla,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=373h77ghg78hh478"/>

Like this:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <system.web>
        <compilation debug="true" defaultLanguage="c#" batch="false" numRecompilesBeforeAppRestart="50" targetFramework="4.0">
            <assemblies>
                <add assembly="my.assembly.blabla,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=373h77ghg78hh478"/>
            </assemblies>
...
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top