Base solution for your next web application
Open Closed

A problem when use L in plus view #2565


User avatar
0
goldstar25 created

1.I has enable PlugInSources:

return services.AddAbp<AdminWebMvcModule>(options =>
            {
                var plusPath = Path.Combine(_hostingEnvironment.WebRootPath, "PlugIns");
                if (!Directory.Exists(plusPath))
                    Directory.CreateDirectory(plusPath);
                options.PlugInSources.AddFolder(plusPath);
            });

2.I write a RazorPageBase.cs :

public abstract class RazorPageBase<TModel> : AbpRazorPage<TModel>
    {
        protected RazorPageBase()
        {
            LocalizationSourceName = DemoConsts.LocalizationSourceName;
        }
    }

3.And add _ViewImports.cshtml:

@using Abp.Localization
@inherits Magicodes.UI.Demo.Views.RazorPageBase<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

4.When I use L method(E.g @L("UICollorCollection")) in view,I will get exception:

An unhandled exception occurred while processing the request.

FileNotFoundException: 未能加载文件或程序集“Magicodes.UI.Demo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)

[attachment=0]exception.png[/attachment]


9 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your code seems correct to me. Let me try the same scenario and get back to you.

    Thanks.

  • User Avatar
    0
    goldstar25 created

    <cite>ismcagdas: </cite> Hi,

    Your code seems correct to me. Let me try the same scenario and get back to you.

    Thanks.

    I use .NET Core. Thanks!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I couldn't repeat the problem, can you send your project to <a href="mailto:[email protected]">[email protected]</a> ?

    Thanks.

  • User Avatar
    0
    goldstar25 created

    I upgraded the project,I'll try again later.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Ok, please let us know if it does not work.

    Thanks.

  • User Avatar
    0
    goldstar25 created

    Now,no exception,but L function not work.I use this code in view:

    <p>
            @L("Test")
            <br />
            @(LocalizationHelper.GetString(TestDemoConsts.LocalizationSourceName, "Test"))
        </p>
    

    It's not work.it print "[Test] ". And the xml content is:

    <?xml version="1.0" encoding="utf-8"?>
    <localizationDictionary culture="en">
      <texts>
        <text name="Test" value="Test Test Test" />    
      </texts>
    </localizationDictionary>
    

    I has config "TestLocalizationConfigurer":

    namespace TestDemo.Localization
    {
        public class TestLocalizationConfigurer
        {
            public static void Configure(ILocalizationConfiguration localizationConfiguration)
            {
                localizationConfiguration.Sources.Add(
                    new DictionaryBasedLocalizationSource(
                        TestDemoConsts.LocalizationSourceName,
                        new XmlEmbeddedFileLocalizationDictionaryProvider(
                            Assembly.GetExecutingAssembly(),
                            "TestDemo.Localization"
                        )
                    )
                );
            }
        }
    }
    

    And write in AbpModule:

    public override void Initialize()
            {
                //设置语言资源
                TestLocalizationConfigurer.Configure(Configuration.Localization);
                IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Does your main module depends on your Test module ?

  • User Avatar
    0
    goldstar25 created

    [attachment=0:3dhby4nm]QQ截图20170309151952.png[/attachment:3dhby4nm]

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think it should be reverse, AdminWebMvcModule should depend on TestModule.