小编Rud*_*udy的帖子

Xamarin.Forms.Xaml.XamlParseException:找不到trans的MarkupExtension:在发布模式下使用PCL进行翻译

我非常绝望地找到了下面提到的问题的解决方案.

我有一个跨平台解决方案,有4个项目,

3 OS特定
    MyApp.android,
    MyApp.Winphone,
    MyApp.IOS
和PCL项目
    MyApp.BLL

在MyApp.BLLbll中,我正在使用MyApp命名空间,在根目录中我有TranslateExtension.cs类

namespace MyApp
{
    [ContentProperty("Text")]
    public class TranslateExtension: IMarkupExtension

{
    readonly CultureInfo ci;
    const string ResourceId = "MyApp.Resources.AppResource";

    public TranslateExtension()
    {
        ci = DependencyService.Get<ILocalize>().GetCurrentCultureInfo();
    }

    public string Text { get; set; }

    public object ProvideValue(IServiceProvider serviceProvider)
    {
        if (Text == null)
            return "";

        ResourceManager resmgr = new ResourceManager(ResourceId
                            , typeof(TranslateExtension).GetTypeInfo().Assembly);

        var translation = resmgr.GetString(Text, ci);
        try
        {
        if (translation == null)
            {
#if DEBUG
                throw new ArgumentException( …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin xamarin.forms

3
推荐指数
1
解决办法
3856
查看次数

标签 统计

android ×1

c# ×1

xamarin ×1

xamarin.forms ×1