Home All Groups Group Topic Archive Search About

SQL 2005, web services, error: Object reference not set to an inst

Author
18 Aug 2006 9:56 AM
Chris
hi,
I am using sql server 2005 and web services of project server 2007. my job
is to write a simple stored procedure that calls project's web services - to
log on to the server, create a project and log out. I can log on.out - these
are working fine. the problem occurs when attempting to create a project. I
am getting the error: Object reference not set to an instance of an object. I
have no idea what is wrong. Exactly the same application launched as .exe
file works fine. The problem is only when I create .dll file and assembly it
in SQL server as stored procedure. the code is as follow:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Net;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace ConsoleApplication11
{
    public class Program
    {
        public static void Main1(string name)
        {
            const string LOGINWINDOWS = "_vti_bin/PSI/LoginWindows.asmx";
            string baseUrl = "http://localhost:22278/projectserver/";
            CookieContainer cookies = new CookieContainer();

            LoginWindowsWebSvc.LoginWindows loginWindows = new
LoginWindowsWebSvc.LoginWindows();
            loginWindows.Url = baseUrl + LOGINWINDOWS;
            loginWindows.Credentials = CredentialCache.DefaultCredentials;

            loginWindows.Login();
            ProjectWebSvc.Project project = new ProjectWebSvc.Project();
            project.Credentials = loginWindows.Credentials;

            project.Url = baseUrl + "_vti_bin/psi/project.asmx";
            ProjectWebSvc.ProjectDataSet dsProject = new
ProjectWebSvc.ProjectDataSet();
            ProjectWebSvc.ProjectDataSet.ProjectRow projectRow =
dsProject.Project.NewProjectRow();
            Guid projectGuid = Guid.NewGuid();
            projectRow.PROJ_UID = projectGuid;
            projectRow.PROJ_TYPE = (int)PSLibrary.Project.ProjectType.Project;
            projectRow.PROJ_NAME = name;
            projectRow.PROJ_SESSION_UID = Guid.NewGuid();
            dsProject.Project.AddProjectRow(projectRow);
            Guid jobGuid = Guid.NewGuid();
            project.QueueCreateProject(jobGuid, dsProject, false);
            System.Threading.Thread.Sleep(5000);
            string wss = "http://localhost:22278/projectserver"+name+"/";
            project.QueuePublish(Guid.NewGuid(),
dsProject.Project[0].PROJ_UID, true, wss);
            System.Threading.Thread.Sleep(5000);
            loginWindows.Logoff();
            project.Credentials = null;
        }
    }
}



---------------------------------------
the problem occurs when calling project.QueueCreateProject(...)

AddThis Social Bookmark Button