0

我正在尝试ProjectServerServices.dll从 Microsoft SharePoint 自定义应用程序页面调用 Microsoft Project Server。我想使用 PSI 访问 PWA 信息。

这是我的示例代码:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using SvcProject;
using SvcQueueSystem;

namespace PWA.PSI.Test1.Layouts
{
    public partial class GetProjectList : LayoutsPageBase
    {
        private const string ENDPOINT_PROJECT = "basicHttp_Project";
        private const string ENDPOINT_RESOURCE = "basicHttp_Resource";

        private static ProjectClient projectClient;
        private static SvcResource.ResourceClient resourceClient;

        protected void Page_Load(object sender, EventArgs e)
        {
            ConfigClientEndpoints(ENDPOINT_PROJECT);
            ConfigClientEndpoints(ENDPOINT_RESOURCE);

            Guid myUid = resourceClient.GetCurrentUserUid();

            lit.Text = "My GUID: " + myUid.ToString();

            // Get list of all projects.
            SvcProject.ProjectDataSet projectDs = projectClient.ReadProjectStatus(
              Guid.Empty, SvcProject.DataStoreEnum.WorkingStore,
              string.Empty, (int)PSLibrary.Project.ProjectType.Project);

            SvcProject.ProjectDataSet tempProjDs = null;

            // Create an empty ProjectDataSet for projects the user owns.
            SvcProject.ProjectDataSet myProjectsDs = (SvcProject.ProjectDataSet)projectDs.Clone();

            for (int i = 0; i < projectDs.Project.Count; i++)
            {
                tempProjDs = projectClient.ReadProject(projectDs.Project[i].PROJ_UID,
                  SvcProject.DataStoreEnum.WorkingStore);

                if (tempProjDs.Project[0].ProjectOwnerID == myUid)
                {
                    lit.Text +=  "</BR>Project -- " + tempProjDs.Project[0].PROJ_NAME   ;
                    myProjectsDs.Project.ImportRow(
                      (SvcProject.ProjectDataSet.ProjectRow)tempProjDs.Project[0]);
                }
            }
        }

        public static void ConfigClientEndpoints(string endpt)
        {
            if (endpt == ENDPOINT_PROJECT)
                projectClient = new SvcProject.ProjectClient(endpt);
            else if (endpt == ENDPOINT_RESOURCE)
                resourceClient = new SvcResource.ResourceClient(endpt);
        }
    }
}

当我在 SharePoint 中打开此自定义应用程序页面时,我收到以下错误消息

无法加载文件或程序集“ProjectServerServices,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。需要强命名程序集。(来自 HRESULT 的异常:0x80131044)

这里有什么问题?

4

1 回答 1

0

您必须首先创建一个强名称密钥

sn -k mykey.snk

然后将 GenWCFProxyAssembly.cmd 中的以下行从

%CSC% /t:library /out:%ASSEMBLY_NAME% %SOURCE%*.cs

%CSC% /t:library /out:%ASSEMBLY_NAME% %SOURCE%*.cs /keyfile:mykey.snk

.dll 将使用强名称进行编译。

于 2016-07-06T13:18:12.127 回答