2013/07/22

the type or namespace name "xxxxxxxxxx" could not be found

[PROBLEM]
在Visual C# 2010,有project B的程式中使用到project A的class AA。AA有設為public,且project B的reference也有加A。
Design time時,在B的程式中用到AA,auto-complete都沒問題。
但是要執行時做build,就出現 the type or namespace name "xxxxxxxxxx" could not be found的錯誤

[SOLUTION]
錯誤主要是來自各project的target framework不一致。剛查了一下,project A的target framework是 ".NET Framework 4",而project B的則是 ".NET Framework 4 Client Profile"。
將project B也設為".NET Framework 4"就沒問題了。

target framework要在那裡設?點選你的project後,主選單 Project | xxxxxx Properties,在Application tab中就可以找到了。

沒有留言: