How can i publish my application , Use Sharepoint API in Web application RRS feed

  • 質問

  • hi teachers

    I made a Web Application using ClientContext.

    But i have problem.

    This is my source

     using (ClientContext clientContext = new ClientContext("http://nar-clxxxx/"))
                    KeywordQuery keywordQuery = new KeywordQuery(clientContext);
                    keywordQuery.QueryText = @"Path:\\";

                    keywordQuery.RowLimit = 200;
                    SearchExecutor searchExecutor = new SearchExecutor(clientContext);
                    ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
                    catch (Exception ee) { Label1.Text = ee.Message; }

                    foreach (var resultRow in results.Value[0].ResultRows)

                            Label1.Text = Label1.Text + resultRow["Title"];


    I can get searchresult If i compile(ctrl+f5).

    But if i publish application return error from results.Value[0].ResultRows

    Errors Message is "Object reference not set to an instance of an object."(this message is translate)

    My develop environment is

    Windows server2008 R2

    Visual Studio2012 professional

    Sharepoint server2013

    site url if try ctrl+f5(http://localhost:56974/WebForm2.aspx)

    site url if try publish application(http://localhost:8080/WebForm2.aspx)

    need your help thank.

    2013年9月20日 4:54