0

This is my first Visual Studio 2010 / SharePoint 2010 Visual Web Part, and my first use of NuGet, so forgive my blinding ignorance. fwiw, this is for SP2010. I'm asking here instead of at sharepoint.stackexchange because I suspect it's more a VS question.

In VS2010, I have a SP2010 Visual Web Part project. It debugs clean and shows a basic "Hello World!" as desired. Looking at VisualWebPart1UserControl.ascx.cs, I have

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;

namespace VisualWebPartProject1.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SPSite site = SPContext.Current.Site;
            SPSite.UsageInfo usage = site.Usage;
            foo.Text = "Hello World!";
        }
    }
}

So far so good. Now what I really want to do on this page will involve some ugly date/time work, so I google, and discover a NuGet package, "TimePeriodLibrary.NET". I get NuGet config'd to work with VS2010, and I add the package to my project. I see the package refeerences added in References, great.

Problem comes when I try this:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Itenso.TimePeriod;

namespace VisualWebPartProject1.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SPSite site = SPContext.Current.Site;
            SPSite.UsageInfo usage = site.Usage;

              TimeRange timeRange1 = new TimeRange(
              new DateTime(2011, 2, 22, 14, 0, 0),
              new DateTime(2011, 2, 22, 18, 0, 0));
              foo.Text = "TimeRange1: " + timeRange1;
        }
    }
}

It looks okay, but when I debug, I get:

"Could not load file or assembly 'Itenso.TimePeriod, Version=1.4.11.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748' or one of its dependencies. The system cannot find the file specified.":"Itenso.TimePeriod, Version=1.4.11.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748"

Being my first use of NuGet (amongst other firsts as you can tell), I was under the impression that it would modify web.config and basically 'make it work'. I've tried in desperation to even manually drag the needed .DLLs into the /BIN folder for the web application, but even that didn't work.

I'll admit it, I'm stumped. Any help would be appreciated.

4

2 回答 2

1

我讨厌回答自己的问题,但我确实让它发挥了作用。 http://jussionsharepoint.com/index.php/2012/02/08/using-global-assembly-cache-tool-gacutil-exe-effectively/ 我找到了.dll,并使用gacutil.exe /i安装它给 GAC。此后,一切都按预期进行。我不能权威地说这是获得预期结果的“正确”方式,但似乎如此。如果这不是让它发挥作用的最佳方式,我对社区希望传递的任何智慧持开放态度。

于 2012-10-22T18:47:04.550 回答
0

您应该右键单击引用,选择属性,并将构建操作设置为“复制到本地”(或类似的东西)

作为旁注,nuget 管理器只执行包内的操作,因此几乎可以肯定,当出现问题时,这不是管理器的错。

于 2012-10-19T23:11:28.153 回答