首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sharepoint编译包含两个相互引用的类库的项目

Sharepoint编译包含两个相互引用的类库的项目
EN

Stack Overflow用户
提问于 2012-11-01 17:03:55
回答 1查看 480关注 0票数 1

我有一个Sharepoint可视化Webpart,它引用了两个类库。这些库协同工作,为Webpart提供值。解决方案构建时没有错误或警告...

代码语言:javascript
复制
1>------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
1>  ClassLibrary1 -> c:\Projects\TempWebPart\ClassLibrary1\bin\Debug\ClassLibrary1.dll
2>------ Rebuild All started: Project: ClassLibrary2, Configuration: Debug Any CPU ------
2>  ClassLibrary2 -> c:\Projects\TempWebPart\ClassLibrary2\bin\Debug\ClassLibrary2.dll
3>------ Rebuild All started: Project: TempWebPart, Configuration: Debug Any CPU ------
3>  TempWebPart -> c:\Projects\TempWebPart\TempWebPart\bin\Debug\TempWebPart.dll
========== Rebuild All: 3 succeeded, 0 failed, 0 skipped ==========

然而,当我按下start按钮来调试它时,它抛出错误并且不能编译...

代码语言:javascript
复制
1>------ Build started: Project: TempWebPart, Configuration: Debug Any CPU ------
1>  TempWebPart -> c:\Projects\TempWebPart\TempWebPart\bin\Debug\TempWebPart.dll
1>  ClassLibrary1 -> c:\Projects\TempWebPart\ClassLibrary1\bin\Debug\ClassLibrary1.dll
1>c:\Projects\TempWebPart\ClassLibrary2\Class2.cs(5,7,5,20): error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

我还收到了以下错误和警告。

代码语言:javascript
复制
Error   1   The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?) c:\Projects\TempWebPart\ClassLibrary2\Class2.cs 5   7   TempWebPart

我已经为两个类库项目添加了对Webpart项目的引用。我还在Package...下的Advanced菜单中为两个类库添加了“来自项目输出的程序集”。

代码语言:javascript
复制
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="0a8bd835-ad91-49a1-a82d-61e22081fbe6" SharePointProductVersion="14.0">
  <Assemblies>
    <Assembly Location="ClassLibrary1.dll" DeploymentTarget="GlobalAssemblyCache" />
    <Assembly Location="ClassLibrary2.dll" DeploymentTarget="GlobalAssemblyCache" />
    <Assembly Location="TempWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="TempWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ef7e45135ca6bea" Namespace="TempWebPart" TypeName="*" />
      </SafeControls>
    </Assembly>
  </Assemblies>
  <FeatureManifests>
    <FeatureManifest Location="TempWebPart_Feature1\Feature.xml" />
  </FeatureManifests>
</Solution>

我的库很简单,只是为了测试这个用例。这是代码。

代码语言:javascript
复制
namespace ClassLibrary1
{
    public class Class1
    {
        public String Hello = "Hello";
    }
}
代码语言:javascript
复制
using ClassLibrary1;

namespace ClassLibrary2
{
    public class Class2
    {
        public String Hello = new ClassLibrary1.Class1().Hello;
    }
}

程序集已签名。我已经在一个WindowsForms应用程序中尝试过了,并且工作正常。我尝试过vb库,出现了类似的信息。我想我在什么地方漏掉了一步。我正在使用vs2012。

我真的被困在要尝试的事情上了:(我很感激任何人的帮助。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2012-11-01 17:12:22

  • 类库的目标框架是什么?它应该是.NET Framework3.5?
  • 您可能需要将这些程序集包含在Package.xml中的Webpart项目中。

希望这能帮上忙..

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13173859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档