我有一个引用两个类库的 Sharepoint 可视化 Webpart。这些库协同工作,为 Webpart 提供值。该解决方案构建时没有错误或警告......
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 ==========
但是,当我按下开始按钮进行调试时,它会引发错误并且不会编译...
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 ==========
我还收到以下错误和警告。
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 Menu 中为两个类库添加了“来自项目输出的程序集”。
<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>
我的库很简单,只是为了测试这个案例。这是代码......
namespace ClassLibrary1
{
public class Class1
{
public String Hello = "Hello";
}
}
using ClassLibrary1;
namespace ClassLibrary2
{
public class Class2
{
public String Hello = new ClassLibrary1.Class1().Hello;
}
}
程序集已签名。我在 WindowsForms 应用程序中尝试过并且工作正常。我已经尝试过 vb 库,并且出现了类似的消息。我想我在某处错过了一步。我正在使用vs2012。
我真的很想尝试:(如果有任何帮助,我将不胜感激。
谢谢