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 に答える