我有一个引用两个类库的Sharepoint可视Web部件。这些库协同工作,为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
我已经为两个classlibrary项目添加了对Webpart项目的引用。 我还在Package ...
下的Advanced菜单中为两个类库添加了“来自项目输出的程序集”<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。
我真的被困在尝试的事情上:(我很感激任何帮助。
由于
答案 0 :(得分:0)
希望这会有所帮助..