添加了引用 log4net.dll,并且添加了命名空间,仍然报错:未能找到类型或命名空间 VS 2010

本文解决了一个常见的VS2010项目中DLL引用问题,即使用了正确的Using语句却在编译时遇到类型或命名空间未找到的错误。问题根源在于项目的目标框架设置为.NET Framework 4 Client Profile,而非完整的.NET Framework 4。通过调整目标框架,即可解决DLL引用失败的问题。

VS2010 项目引用了DLL文件,也写了Using,但是编译时提示:未能找到类型或命名空间名称

删掉两个dll重新引用,再编译依然报错……

解决方法:

在项目上点右键–>属性–>应用程序–>目标框架–>修改为.NET Framework 4。

原本的设置是.NET Framework 4 Client Profile。问题就出在这里。

以下是MSDN给出的提示:

If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4.

当在 Visual Studio 2010 建立新项目时,如果发现 添加引用 中没有列出原本应该列出的组件或者引用的其他程序集,在代码中的调用一直提示找不到名字空间时,可以先检查是否是项目的 target framework 设成了 .NET 4.0 Client Profile

System.IO.FileNotFoundException: Could not find file "/Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Bundles/Code/Unity.Model.dll.bytes" File name: '/Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Bundles/Code/Unity.Model.dll.bytes' at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <ffede847aa21468d8e163d4cea4bee49>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <ffede847aa21468d8e163d4cea4bee49>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) at System.IO.File.ReadAllBytes (System.String path) [0x00000] in <ffede847aa21468d8e163d4cea4bee49>:0 ET.CodeLoader.Start () [0x000d8] /Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Scripts/Loader/CodeLoader.cs:62 ET.Init.StartAsync () [0x001e0] /Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Scripts/Loader/MonoBehaviour/Init.cs:41 ET.ETTask.GetResult () [0x00030] /Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Scripts/ThirdParty/ETTask/ETTask.cs:126 ET.ETTask.InnerCoroutine () [0x00018] /Users/zhoufeng/mmzhu/ET-release8.1/Unity/Assets/Scripts/ThirdParty/ETTask/ETTask.cs:71 UnityEngine.Debug:LogError (object) ET.UnityLogger:Error (string) (at Assets/Scripts/Loader/UnityLogger.cs:33) ET.Log:Error (System.Exception) (at Assets/Scripts/Core/World/Module/Log/Log.cs:76) ET.AsyncETVoidMethodBuilder:SetException (System.Exception) (at Assets/Scripts/ThirdParty/ETTask/AsyncETVoidMethodBuilder.cs:33) ET.ETTask/<InnerCoroutine>d__10:MoveNext () (at Assets/Scripts/ThirdParty/ETTask/ETTask.cs:71) ET.StateMachineWrap`1<ET.ETTask/<InnerCoroutine>d__10>:Run () (at Assets/Scripts/ThirdParty/ETTask/StateMachineWrap.cs:56) ET.ETAsyncTaskMethodBuilder:SetException (System.Exception) (at Assets/Scripts/ThirdParty/ETTask/AsyncETTaskMethodBuilder.cs:35) ET.Init/<StartAsync>d__1:MoveNext () (at Assets/Scripts/Loader/MonoBehaviour/Init.cs:41) ET.StateMachineWrap`1<ET.Init/<StartAsync>d__1>:Run () (at Assets/Scripts/ThirdParty/ETTask/StateMachineWrap.cs:56) ET.ETTask:SetResult () (at Assets/Scripts/ThirdParty/ETTask/ETTask.cs:145) ET.ETAsyncTaskMethodBuilder:SetResult () (at Assets/Scripts/ThirdParty/ETTask/AsyncETTaskMethodBuilder.cs:47) ET.ResourcesComponent/<CreatePackageAsync>d__2:MoveNext () (at Assets/Scripts/Loader/Resource/ResourcesComponent.cs:85) ET.StateMachineWrap`1<ET.ResourcesComponent/<CreatePackageAsync>d__2>:Run () (at Assets/Scripts/ThirdParty/ETTask/StateMachineWrap.cs:56) System.Threading.Tasks.TaskCompletionSource`1<object>:TrySetResult (object) YooAsset.AsyncOperationBase:SetFinish () (at ./Library/PackageCache/com.tuyoogame.yooasset@2.1.1/Runtime/OperationSystem/AsyncOperationBase.cs:111) YooAsset.OperationSystem:Update () (at ./Library/PackageCache/com.tuyoogame.yooasset@2.1.1/Runtime/OperationSystem/OperationSystem.cs:83) YooAsset.YooAssets:Update () (at ./Library/PackageCache/com.tuyoogame.yooasset@2.1.1/Runtime/YooAssets.cs:84) YooAsset.YooAssetsDriver:Update () (at ./Library/PackageCache/com.tuyoogame.yooasset@2.1.1/Runtime/YooAssetsDriver.cs:13) 报错
07-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值