錯誤一
在一個文件夾中能正常運行的mfc工程文件
復制到另一個文件夾就運行不了
給文件夾更名
也會導致該工程文件不能運行
而且這種影響是不可逆的!
(暈)
原因:
工程文件夾的路徑不能更改!
--------更新-------
現在這個問題已經得到了解決
錯誤二
對 COM 組件的調用返回了錯誤 HRESULT E_FAIL
刪除工程文件夾下 .user .filters 文件后可以消除這個錯誤。
錯誤三
錯誤四
錯誤五
錯誤六
關掉預編譯即可。
項目
屬性
配置屬性
C/C++
預編譯頭
創建/使用預編譯頭
選擇不使用預編譯頭
錯誤七
錯誤八
資源視圖 在另一個編輯器中打開
解決辦法:
一般這種情況是打開了頭文件中的resource.h造成的,關閉resource.h,在資源視圖中重新打開即可。(雙擊.rc再雙擊)
如圖:
錯誤九
把重復的函數封上
錯誤十
找不到對話框編輯器
結束調試就有了
錯誤十一
函數刪除失敗
要想刪除一個函數,先刪代碼,再去屬性刪去
如果直接在屬性中刪除,vs會直接把代碼注釋掉,但是不能再次添加,會顯示未刪除
錯誤十二
焦點要從控件離開,曲線才更新,不能在值改變的瞬間立即更新
這不是OnEnKillfocusThreshold的功能
OnEnKillfocusThreshold是在焦點離開的時候才執行
並不是值改變是執行
值改變就執行的是這個函數
EN_CHANGE
這樣才能觸發更新和重繪
void CDlgTest1::OnEnChangeThreshold() { //更新到內存 UpdateData(TRUE); //重繪 InvalidateRect(m_MouseRect, TRUE); }
錯誤十三
錯用false,編輯框導致不管輸入什么數,都會立刻變回128
這是因為false是內存->控件。m_middle1內存初始值128
正確用法是控件到內存,就是true
UpdateData(true); //用於將屏幕上控件中的數據交換到變量中。控件->內存。 UpdateData(false); //用於將數據在屏幕中對應控件中顯示出來。內存->控件。
錯誤十四
在這里修改ID是錯誤的,修改完的ID會報錯,顯示 C0022 ID_XXX未定義
必須在下圖改
在這里改才能被鏈接,系統會自動修改一些參數,在上面改是無效的
實際上改ID是為ID做一個define
錯誤十五
MFC修改ID時閃退
查詢到如下信息(鏈接)
錯誤描述:
VS resource editor badly broken
Visual Studio (2019 Community, v16.2.0) crashes if I try to edit any string (menu, dialog etc) with the Resource Editor.
This happens even with a completely new build. To reproduce:Start VS, select New Project, MFC
Accept all defaults.
Build.
Open Resource View: Menu
double-click IDR_MAINFRAME
Type “dummy thing” in the edit box at the bottom of the File menu
Open Properties view and select the menu item “dummy thing”
Edit the Caption by adding “xxx” to end of string so it reads “dummy thing xxx”
Sit back and wait for crash - which happens within about 3 seconds.VS crashes and restarts. The menu edit has been lost.
I have run Repair on VS, but the problem persists.
評論:
一:
I have now also re-installed VS, to no avail.
However, I suspect the problem is with using a HiDPI monitor (a Lenovo Thinkvision driven by a MacBook Pro running Windows in bootcamp).I have tried VS on another computer with a standard monitor, and it works fine with the same resource file.二:
A fix for this issue has been internally implemented and is being prepared for release. We’ll update you once it becomes available for download.
三:
VS2019 16.3 preview 1 already includes this fix, you could get it from: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview
四:
I tried with Visual Studio Professional 2019 version 16.3.0 preview 4.0, but it has not been fixed. I used old compilers and MFC. Do I need to use new ones? If not, it may be incompatible with the Japanese IME. I can use it in English without problems.
五:
I can confirm that the VS2019 16.3 does not contain the fix of this issue.
六:
Updated to VS2019 16.3.2, which does not contain this fix. The entire IDE still crashes when I attempt to edit a property.
七:
This issue has been identified as a duplicate of an earlier reported feedback linked here: https://developercommunity.visualstudio.com/content/problem/669039/when-try-to-change-the-properties-of-a-menu-item-i.html. If you reported or voted here, your vote has been applied to the original issue. Everyone else can add their vote directly at the above linked feedback. Voting helps increase the priority of the issue by consolidating customer impact under one feedback. Thank you!
最終解答:
Hi all,
Please go to Settings > Update & Security > Windows Update, and then select Check for updates>>download and install the new update, then restart OS.
October 24, 2019-KB4522741 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1903 and Windows Server 1903 RTM: https://support.microsoft.com/en-us/help/4522741/oct-24-2019-kb4522741-cumulative-update-for-net-framework
評論一:
Now that you mention it, I would also be interested to know how this is a Windows issue rather than being specific to VS2019.
評論二:
It sounds like its a bug in the .NET framework itself (rather than Visual Studio) and therefore it has to be pushed as part of a .NET framework update (which goes out over Windows Update) rather than as part of a Visual Studio update.
錯誤十六
MFC閃退后menu和對話框編輯界面打不開
重啟試試
錯誤十七
經歷多次閃退貌似框架壞了
回去把與該控件有關的內容全部刪除
成功恢復框架
錯誤十八
千萬不要直接刪除部分菜單,框架會崩潰
錯誤十九
錯誤二十
改為以下三個中的一種:
AfxMessageBox("請輸入文件路徑文件名!!");
AfxMessageBox(_T("請輸入文件路徑文件名!!"));
AfxMessageBox(L"請輸入文件路徑文件名!!");
錯誤二十一
error C2665: “AfxMessageBox”: 2 個重載中沒有一個可以轉換所有參數類型)。
解決方法:選擇“項目”菜單->項目屬性->配置屬性->常規->字符集,改為“未設置”即可。
錯誤二十二
error LNK1120: 1 個無法解析的外部命令
有兩個原因:
1.只包含了頭文件,只有這個函數的聲明,沒有包含這個函數的實現(實現一般放在cpp文件中的)。所以只能通過編譯,連接不成功。
2.另一個原因是函數的聲明和實現都放在頭文件中了,一般要把聲明放頭文件中,實現放在cpp文件中。這樣每個#include該頭文件的文件都會有一份該函數的實現,連接的時候,連接器不知道連接哪一個實現,於是報錯。
錯誤二十三
error C2601: “...”: 本地函數定義是非法的
有可能是前面少了一個大括號,導致你后面定義函數時被前面的函數包了進去!
錯誤二十四 原文
找不到"no_init_all"的attribute。錯誤源頭在winnt.h這一系統頭文件中
只需要在winnt.h頭文件中
#if (_MSC_VER >= 1915) #pragma warning(disable:4845) // __declspec(no_init_all) used but d1initall not set #endif
這一預編譯頭之后加上
#if (_MSC_VER >= 1915) #define no_init_all deprecated #endif
即可消除錯誤提示
錯誤二十五
error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支持默認 int
有以下原因:
1. 如果存在兩個類的頭文件a.h和b.h,在a.h中有這樣的語句:#include "b.h",在b.h文件中有這樣的語句:#include "a.h" 且在一個類中有另一個類的對象時 那么就會出現這樣的錯誤。
2. 沒有包含要定義的類的頭文件。
3.項目中少加了宏定義,導致頭文件重復定義或相應宏無法識別。
4.當有多個頭文件時,順序寫反也可能導致相關的錯誤,其根本是頭文件中的預編譯語句被隱去了。
錯誤二十六
無法解析的外部符號
僅僅添加頭文件,沒有添加對應源文件