‘SQLHelper’ is not declared. It may be inaccessible due to its protection level.

今天把一個由VS2005 .Net Framework 2.0 寫的程式
重新用 VS2010 寫的時候…
在更用ShareChiWaiLib
出現了這個錯誤信息..
‘SQLHelper’ is not declared. It may be inaccessible due to its protection level.
和以下的 Warning
Namespace or type specified in the Imports ‘ShareChiWaiLib’ doesn’t contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn’t use any aliases.
The referenced assembly “ShareChiWaiLib” could not be resolved because it has a dependency on “System.Web, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project. 

 

我便在想..我在其他程式中也選用 這個 ShareChiWaiLib 的 SQLHelper 來處理一些和SQL 相關的 程序…
不知道為何在這個新建立的應用程式才出現問題…
最後終於找到了解決方法
其實這是因為我的Visual Studio 2010 的Default Setting 是用 .Net Framework 4 Client Profile
而有些 .Net Framework assemblies 又不在.Net Framework 4 Client Profile
所以便出現這個 問題了

解決方法:
打開你的Project 內容 E.G. 雙按 “My Project
之後選擇 “Compile Tab 分頁
按一下”Advanced Compile Options
Target framework (all configurations): 的選項中選擇
.NET Framework 4” 便可
Hope you find it useful

Leave a Reply