顯示具有 automapper 標籤的文章。 顯示所有文章
顯示具有 automapper 標籤的文章。 顯示所有文章

AutoMapper升級至4.1.1後出現ProfileName錯誤

AutoMapper升級至4.1.1後專案無法編譯

AutoMapper ProfileName Error

早上升級專案 AutoMapper 套件到最新版(4.1.1)後,發現專案無法通過編譯,查看錯誤訊息,看來是 AutoMapper 4.1.1 的屬性有些改變。

Profile.ProfileName

錯吳訊息

'xxx.ProfileName': cannot override inherited member 'Profile.ProfileName' because it is not marked virtual, abstract, or override

很明顯,新版本改變了 ProfileName 的存取方式,查詢AutoMapper Releases沒查到什麼有用的資訊。

按下F12查詢 Profile 類別的定義:

AutoMapper Profile 定義

ProfileName 屬性僅能 get,再看看建構式,解法很明顯了: