【问题标题】:ResourceManager returns name of fileResourceManager 返回文件名
【发布时间】:2018-01-18 16:26:12
【问题描述】:

我有一个 .net-core 2.0 控制台应用程序。 此应用程序引用了一个 .net-standard-2.0 库,其中包含一个资源文件 SqlStatements.resx,其中包含多个 sql 文件。

文件配置: 嵌入式资源; 禁止抄袭; ResXFileCodeGenerator;

如果我在 Visual Studio 2017 中以调试或发布模式调用它

var result = SqlStatements.somefileName;

我得到了文件的内容。 但是如果在服务器上启动代码,我会得到类似:

resources\somefileName.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8

我以这种方式启动应用程序:

dotnet MyApp.Console.dll

你知道这可能是什么原因吗?

更新: 代码是正确的: 我已经用 dotpeek 检查了 dll。如果我运行脚本:

dotnet build SolutionName.sln --configuration -Release

那么resource.resx 中的值看起来像

resources\somefileName.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8

如果我在 Visual Studio 中进行构建,则 resx 没问题(我看到了 sql 文件的内容)。

【问题讨论】:

  • 你可以试试这个using (ResXResourceSet resxSet = new ResXResourceSet(resxFile))然后var text = resxSet.GetString("Title");
  • 嗨 @AntonGorbunov 不幸的是 ResXResourceSet 来自 WinForms。我有一个 .net-core 2.0 控制台应用程序

标签: c# .net-core resourcemanager .net-standard-2.0


【解决方案1】:

它在本地工作,因为 Visual Studio 使用 MsBuild 并且能够使用嵌入式资源。我已将 sql 移到代码中

【讨论】:

  • 它没有回答问题,这是一种解决方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多