2012-08-16 117 views
2

如果我回顧我的測試解決方案的的.csproj我看到國旗如下:的CodeDOM - XML標記到一些常識

<ItemGroup> 
<Reference Include="Interop.Encore"> 
<HintPath>..\..\..\..\..\..\\Interop.Encore.dll</HintPath> 
**<EmbedInteropTypes>False</EmbedInteropTypes>** 
</Reference> 
<Reference Include="System" /> 
<Reference Include="System.Core" /> 
<Reference Include="System.Xml.Linq" /> 
<Reference Include="System.Data.DataSetExtensions" /> 
<Reference Include="Microsoft.CSharp" /> 
<Reference Include="System.Data" /> 
<Reference Include="System.Xml" /> 
</ItemGroup> 

我的問題SI我需要的EmbedInteropTypes設置爲false CodeDOM的項目中在它自己生成一個.DLL之前。 (DLL不包含EmbedInteropType DLL)

任何人都有解決方案嗎?

我看

_CurrentCodeFile.AssemblyCustomAttributes.Add(
    new CodeAttributeDeclaration("EmbedInteropTypes", new CodeAttributeArgument[] { new 
     CodeAttributeArgument(
     new CodePrimitiveExpression(false))})); 

有什麼建議?

回答

0

首先,我想你誤解了什麼裝配屬性。他們通常被放置在AssemblyInfo.cs,看起來像[assembly:AssemblyCultureAttribute("de")]。並且我沒有找到EmbedInteropTypes屬性。

現在,基於我使用CodeDOM引用COM程序集的測試,如果您不想嵌入interop程序集,只需引用它就不需要執行任何特殊操作。另一方面,如果你確實想嵌入它,你需要明確地使用the /link command line option,設置CompilerOptions

+0

其次,使用/ link命令不會給你禁止(不提供)或其他形式的標誌鏈接文件... afaik。我可能是錯的 - 我們可以在泰國再次喝酒... – Chris 2012-08-16 17:59:34

+0

我不確定你在說什麼,但我肯定不會去8000公里到泰國只是爲了喝酒你:-) – svick 2012-08-16 18:13:42