简体   繁体   English

无法加载文件或程序集Sharepoint 2007 WebPart

[英]Could Not Load File or Assembly Sharepoint 2007 WebPart

I am playing around with Sharepoint 2007. I have a virtual machine (win server 2k3) with an instance of sharepoint server 2007 running on it. 我正在玩Sharepoint2007。我有一台运行了sharepoint Server 2007实例的虚拟机(win服务器2k3)。 I am now working on creating web parts. 我现在正在创建Web部件。 I have successfully created simple ones, such as this one that displays text: 我已经成功创建了简单的示例,例如显示文本的示例:

public class SimpleWebPart : WebPart
{
    private string _displayText = "Hello World!";
    [WebBrowsable(true), Personalizable(true)]
    public string DisplayText
    {
        get { return _displayText; }
        set { _displayText = value; }
    }
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        writer.Write(_displayText);
    }
}

I have this one (and a few test ones) inside of a Class Library, which I put into the _app_bin folder inside of C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\80 . 我在一个类库中拥有一个(和一些测试类),并将其放入C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\80_app_bin文件夹中。

The latest one I added utilizes LINQ to get data from a table I added (not part of Sharepoint): 我添加的最新文件利用LINQ从我添加的表(不是Sharepoint的一部分)中获取数据:

public class SimpleDBWebPart : WebPart
{
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        var oDB = new SPWebPartDataClassesDataContext();
        var oRes = oDB.GetAllFirstTable();

        foreach(var item in oRes)
        {
            writer.Write("<div>Item Name: {0}</div>",item.text);
            writer.Write("<div>Item ID: {0}</div>", item.id);
        }
    }
}

The GetAllFirstTable() is a stored procedure that gets all the data from my test table: GetAllFirstTable()是一个存储过程,可从我的测试表中获取所有数据:

ALTER PROCEDURE dbo.GetAllFirstTable
AS
    SELECT * FROM FirstTable
    RETURN

When I try to add the WebPart to a page, I get this error: 当我尝试将WebPart添加到页面时,出现以下错误:

The "SimpleDBWebPart" Web Part appears to be causing a problem. Web部件“ SimpleDBWebPart”似乎引起了问题。 Could not load file or assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. 无法加载文件或程序集“ System.Data.Linq,版本= 3.5.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089”或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。

I used Reflector to make sure I have the assembly inside the DLL: 我使用Reflector来确保我在DLL中具有程序集: 替代文字

And that appears to be the case. 事实就是如此。 Do I have to add the assembly to the web.config file of the sharepoint site? 我是否必须将程序集添加到共享点站点的web.config文件中? Or is there something else that I am missing? 还是我还缺少其他东西?

Thanks guys! 多谢你们!

To use LINQ or .NET 3.5 feature you need to first configure the SharePoint to run in 3.5 Mode. 若要使用LINQ或.NET 3.5功能,您需要首先将SharePoint配置为以3.5模式运行。 Refer to these links on how to do that 请参阅这些链接以了解如何执行此操作

Simplest way 最简单的方法

AnotherOne 另一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM