【问题标题】:Trying to call 'ProjectServerServices.dll results in "A strongly-named assembly is required." error尝试调用“ProjectServerServices.dll”会导致“需要强命名程序集”。错误
【发布时间】:2016-07-01 12:00:17
【问题描述】:

我正在尝试从 Microsoft SharePoint 自定义应用程序页面调用 Microsoft Project Server ProjectServerServices.dll。我想使用 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)

这里有什么问题?

【问题讨论】:

    标签: c# dll sharepoint-2013 strongname ms-project-server-2013


    【解决方案1】:

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

    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 将使用强名称进行编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多