2016-07-15 123 views
3

在.Net Core中,對資源生成的resx/designer.cs文件需要的API進行了一些更改。.Net Framework .resx可移植性至.Net Core

具體Type不再直接擁有Assembly屬性就可以了......核心得到這個通過Type.GetTypeInfo().Assembly

結果是designer.cs文件是框架之間的不兼容,所以多針對性的解決方案不能使用資源文件無需編譯失敗:

ConnectionDetails.Designer.cs(42,170): error CS1061: 'Type' does not contain a definition 
for 'Assembly' and no extension method 'Assembly' accepting a first argument of type 'Type' 
could be found (are you missing a using directive or an assembly reference?) 

的Visual Studio知道如何根據項目/解決方案,這些類型生成正確的,但對於多針對性的解決方案,這是沒有太大的幫助。

我一直沒能找到一個適用於這兩個框架的解決方法,因爲designer.cs是自動生成的。

有沒有人想出解決方案呢?

回答

1

這是a known bug,這是由於Visual Studio僅使用目標框架列表中的第一項來實現Resx代碼生成。解決方法是移動的.Net核心或.Net的標準框架,在目標框架列表中的第一位置,即

<PropertyGroup> 
    <TargetFrameworks>netstandard1.0;netstandard1.3;net45</TargetFrameworks> 
</PropertyGroup>