2012-11-01 56 views
1

我有一個引用兩個類庫的Sharepoint可視Web部件。這些庫共同爲Web部件提供值。該解決方案基於沒有任何錯誤或警告....Sharepoint編譯項目包含兩個相互引用的類庫

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 

我已經添加到Web部件項目引用兩個classlibrary項目。 我還添加了「從項目的組件輸出」兩個類庫中包下高級菜單...

<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

不...目前還沒有:( – Sprouts

回答

0
  • 什麼是類庫的目標框架?應該是.NET Framework 3.5?
  • 您可能需要在Web部件項目在package.xml中這些程序集。

希望這有助於..

+0

這兩個類庫都是3.5。 我已經包含了組件。 下面是XML ... \t \t <彙編位置= 「ClassLibrary1.dll」 DeploymentTarget = 「GlobalAssemblyCache」/> \t \t <彙編位置= 「ClassLibrary2.dll」 DeploymentTarget = 「GlobalAssemblyCache」/> – Sprouts

相關問題