尝试调用 'ProjectServerServices.dll 导致 "A strongly-named assembly is required." 错误
Trying to call 'ProjectServerServices.dll results in "A strongly-named assembly is required." error
我正在尝试从 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 中打开此自定义应用程序页面时,我收到以下错误消息
Could not load file or assembly 'ProjectServerServices,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. A strongly-named assembly is required. (Exception from
HRESULT: 0x80131044)
这里有什么问题吗?
您必须先创建一个强名称密钥
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。
我正在尝试从 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 中打开此自定义应用程序页面时,我收到以下错误消息
Could not load file or assembly 'ProjectServerServices, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
这里有什么问题吗?
您必须先创建一个强名称密钥
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。