解決 VS2022 無法偵錯 32 位元 Web Site Project 問題
source link: https://blog.darkthread.net/blog/debug-32bit-wsp-on-vs2022/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
解決 VS2022 無法偵錯 32 位元 Web Site Project 問題-黑暗執行緒
Visual Studio 從 2022 起轉為 64 位元,4GB 封印解除,自此編輯測試時可以充分利用開發機記憶體,面對複雜專案也不用怕。
不過,從 32 位元改為 64 位元有帶來一些後遺症,過去已經歷過:
第二點比較麻煩,典型案例是引用 ODP.NET 的 Web Site Project (WSP) 專案,這類古蹟專案多半還未升級到 Managed ODP.NET,不時會陷入 32 位元 vs 64 位元或 Oracle Client 不匹配的版本地獄,在 VS2022 上爆發只是剛好而已。(衷心建議,若能換 Managed ODP.NET 就塊陶吧~)
因此,若你是用 VS2022 維護呼叫 32 位元 ODP.NET 程式庫的 WSP 專案,便會陷入無法偵錯的困境。
例如,用一個超簡單的 WSP 當範例,專案參照 32 位元 ODP.NET (Oracle.DtaAccess.dll.refresh 內容為 ..\..\Oracle\product\12.2.0\client32\odp.net\bin\4\Oracle.DataAccess.dll
),寫個 WebForm 測試:
<%@Page Language="C#"%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
var asm = typeof(Oracle.DataAccess.Client.OracleConnection).Assembly;
Response.ContentType = "text/plain";
Action<string> write = (m) => Response.Write(m + "\n");
write(Environment.Is64BitProcess ? "64bit" : "32bit");
write(asm.FullName);
}
</script>
試著偵錯或建置網站會出現不認得 Oracle.DataAccess.Client 錯誤:(原因是 VS2022 為 64 位元環境無法載入 32 位元版本 Oracle.DataAccess.dll)
但發佈網站或是 MSBuild 跑 publishproj 則會成功。
改參照 64 位元 ODP.NET,則 WSP 專案可以建置專案及偵錯,變成發佈時出現 32/64 版本不符錯誤:
Deadlock!
原以為無解,但意外找到一個簡單解法 - 偵錯時不要 Build 就好了! 在專案設定頁面將 Start action 的 Before running startup page 設成 No Build:
另外,記得停用 IIS Expression 64 位元模式:
調整後,就可以正常 F5 偵錯了,也能成功發佈 32 位元版本網站檔案,唯一的小問題 Visual Studio 跑 Build Web Site 還是會報錯。實測 .sln 參照的其他專案若有修改,Build Web Site 時會先被編譯才出錯,故古蹟維修可以順利進行,問題算是解決囉~
最後再勸世一下:珍惜生命,遠離 ODP.NET,若狀況允許快換成 Managed ODP.NET 吧!
- Posted in
- ASP.NET
and has 0 comments
Comments
Be the first to post a comment
Post a comment
CommentRecommend
-
11
-
10
Vault 裡 AppRole 的設計,以及怎麼解決 Secret Zero 問題Vault 是 HashiCorp
-
4
重寫 Ptt 上的 Imgur Userscript 解決圖片出不來的問題 前幾個禮拜 Imgur 決定擋掉 Ptt 的網頁版,所以 Ptt 網頁版上會發現 Imgur 的圖都不見了:「
-
10
一鍵解決遊戲 DRM 相容性問題,GIGABYTE Z690 主機板開放 DRM Fix Tool 下載 部分遊戲的 DRM 機制與 Alder Lake-S 處理器架構不相容,會導致遊戲運作異常。
-
7
如何完美解決 PowerShell 無法正確解析命令列參數的問題 這十幾年來,在 Windows 使用 PowerShell 呼叫一些命令列工具,一直都存在一個惱人的問題,那就是傳入 *.exe 的參數會自動將雙引號(")過濾掉,導致程式無法正確執行。...
-
2
VS2022 之 .NET 6 SDK 支援版本問題-黑暗執行緒 前陣子遇到一個 AddRazorRuntimeCompilation() 問題,靠 .NET 6 SDK 更新到 6.0.201 版解決,升級後繼續用 VSCode 開發、測試,一路順...
-
5
密碼重置是一個很常見的功能,通常都是發一個帶有 token 的連結來讓用戶把密碼重置,也因為有帶了 token,我們系統才可以知道「現在在重置密碼的人是誰」。所以你有可能拿到一個連結長這樣http://mywebsite.com/resource/password/edit?r...
-
10
【茶包筆記】升級 VS2022 後老專案無法編譯-黑暗執行緒 VS2019 升級 VS2022 後遇到第一個升級後無法編譯的專案,幸好問題不大,還學會快速檢查 NuGet .nupkg 的技巧。 有個古老專案,歷經 VS2015、VS2017、VS2019 多個世...
-
8
【笨問題】VS2022 Solution Explorer 無法使用關鍵字尋找屬性、方法-黑暗執行緒 在 Visual Studio 的 Solution Explorer 搜索欄輸入關鍵字快速找到類別、屬性或方法,是我開發時不可或缺的功能:(以下為 Visual Studio 2019 操...
-
5
用 MSBuild 事件解決 ASP.NET Core 發佈 IIS 目錄之 DLL 鎖定問題-黑暗執行緒 開發測試 ASP.NET 專案我有個常用的小技巧 - 將 publish 輸出目的地設成 IIS 應用程式主目錄。如此不用啟動 Visual Studio 也能測試,每次修改程式後,使用指令 ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK