【问题标题】:Error adding webpart添加 Web 部件时出错
【发布时间】:2026-01-03 15:50:02
【问题描述】:

我正在使用 VS2012 在 Sharepoint 2013 中开发一个 Web 部件。在这个 webpart 中,我使用了我创建的自定义 dll。库框架是 4.0,可视化 webpart 框架是 4.5。

问题是我在sharepoint页面添加webpart时,出现如下错误:

Could not load file or assembly 'RulesDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2371e81bc184aa5' or one of its dependencies. The system cannot find the file specified

在谷歌搜索我发现了很多解决这个问题的解决方案

  • 使用两种方法将库添加到 GAC。

    (1) gacutil -i RulesDll.dll

    (2) 使用 package ---> VS2012 解决方案资源管理器中的高级选项

当我在 VS 命令提示符下运行 gacutil -l RulesDll 时,一切正常:

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.17929
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  RulesDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2371e81bc184aa5,    processorArchitecture=x86

项目数 = 1

所以库在 GAC 中。

  • 将库添加到 web.config 中的保存控件

但是没有任何效果。有人知道为什么无法在共享点页面中添加我自己的 Web 部件吗?

【问题讨论】:

    标签: visual-studio-2010 sharepoint-2010 visual-studio-2012 web-parts sharepoint-2013


    【解决方案1】:

    当您的程序集在 GAC 中并尝试在页面上添加 Web 部件时,您会遇到什么错误?

    检查您的应用程序的 web.config,尤其是 SafeControls 部分,应该有对您的程序集的引用。

    http://technet.microsoft.com/en-us/library/cc261736.aspx

    【讨论】:

      【解决方案2】:

      终于找到错误了。所有库都必须部署在 x64 中

      【讨论】: