System.NotImplementedException错误

时间:2011-11-15 19:08:53

标签: c#

我正在使用ASP.NET 3.5。我做了一个表单,当用户点击一个按钮时,它应该在另一个页面上添加有关它的信息。而不是加载我得到这个错误页面:

The method or operation is not implemented. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotImplementedException: The method or operation is not implemented.

Source Error: 

    public static dsPersonnel GetPersonnel(string p)
    {
       throw new NotImplementedException();
    } 

Source File:    Line: 203 

我不确定我需要在这里发布什么才能提供足够的帮助信息。

以下是错误可能出现的代码。我想我可能有点不合适的地方:

    public clsDataLayer()
    {

    }

    // This function gets the user activity from the tblPersonnel
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        //create the connection string 
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
        "Data Source=" + Database);

        string query;
        if (strSearch == "" || strSearch.Trim().Length == 0)
        {
            query = "SELECT * from tblPersonnel";
        }
        else
        {
            query = "select * from tblPersonnel where LastName = '" + strSearch + "'";
        }


        // Defines sqlDA and what each will consist of
        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        // Defines DS and what each will consist of
        DS = new dsPersonnel();

        // Outputs the results from the information gathered
        sqlDA.Fill(DS.tblPersonnel);

        // Starts over for a new user
        return DS;
    }

    // This function saves the user activity
    public static void SavePersonnel(string Database, string FormAccessed)
    {
        // Defines the connection to the database
        OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);
        conn.Open();
        OleDbCommand command = conn.CreateCommand();
        string strSQL;

        strSQL = "Insert into tblPersonnel (UserIP, FormAccessed) values ('" +
            GetIP4Address() + "', '" + FormAccessed + "')";

        command.CommandType = CommandType.Text;
        command.CommandText = strSQL;
        command.ExecuteNonQuery();
        conn.Close();

    }

    public static dsPersonnel GetPersonnel(string p)
    {
        throw new NotImplementedException();
    }
}

6 个答案:

答案 0 :(得分:12)

您调用的特定方法(考虑它不是类库方法)很可能是专门执行此操作:

 throw new NotImplementedException();

现在是个存根。这是您的解决方案中的代码;所以在你的页面上,你的方法可能没有实现。

答案 1 :(得分:3)

您或其他人可能使用Visual Studio自动代码生成技术添加了GetPersonnel()方法,该技术会在代码中插入NotImplementedException行,您必须手动删除它。

GetPersonnel()方法中,删除throw new NotImplementedException ...行,并完全实现该方法以返回与方法的返回类型匹配的值。

答案 2 :(得分:1)

此错误表示您正在加载的页面未实现在加载过程中由其代码访问的GetPersonnel方法。我认为您应该检查正在加载的页面的来源并实现此方法。

答案 3 :(得分:0)

这正是错误所说的。你有一行代码,你抛出一个未实现的异常。看这里:

第201行:public static dsPersonnel GetPersonnel(string p)第202行:{第203行:抛出新的NotImplementedException();第204行:}第205行:}

答案 4 :(得分:0)

对于初学者,请尝试以下代码来注释或删除该代码段

   throw new NotImplementedException();

答案 5 :(得分:0)

如果您不知道应该返回什么,只需注释一下这段代码

if UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(url.absoluteString) { UISaveVideoAtPathToSavedPhotosAlbum(url.absoluteString, self, #selector(self.didSaveVideo), nil) } else { return /* do something*/ } @objc private func didSaveVideo(videoPath: String, error: NSError, contextInfo: Any) {}

并替换为

throw new NotImplementedException();