简体   繁体   中英

How to resolve this object reference error in web.config

I am receiving the following error in my web.config.

Parser Error Message: Object reference not set to an instance of an object.
Source File: D:\Webs\behi100001\web.config    Line: 82 

The specific error line is "type="Microsoft.Samples.SqlTableProfileProvider"

<providers>
            <clear/>
            <add name="TableProfileProvider"
              type="Microsoft.Samples.SqlTableProfileProvider"
                connectionStringName="conBTWSqlExpress"
                table="Profile_Custom"
                applicationName="Harbor"/>
        </providers>

I have a file in my App_Code directory with the namespace Microsoft.Samples, with a class called SqlTableProfileProvider. I am not sure what I am doing wrong.

Any help?

Thanks, Kevin

You might have to change

type="Microsoft.Samples.SqlTableProfileProvider" to  type="Microsoft.Samples.SqlTableProfileProvider, Microsoft"

I think you have to include the assembly name, not just the namespace.

Change your type to:

type="Microsoft.Samples.SqlTableProfileProvider, <your assembly's name>"

where is... well your assembly's name. I think because the the sample class is in your App_code, it is compiled into your assembly.

我的直觉是您的连接字符串错误,或者您的应用程序无权访问数据库。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM