小编use*_*804的帖子

如何访问IKVM移植的Java库的.net资源

我正在使用IKVM将一些java库移植到我的c#项目中.库api(StanfordNLP)要求加载文件以训练nlp函数使用的统计模型.从文件系统加载文件已经好几周了,但我现在想将文件作为嵌入式资源添加到dll中,而不是从文件系统中检索它.

问题是java api没有找到.net嵌入式资源.

以下是从文件系统检索文件时有效的代码片段:

public class SNLPModel
{
   public LexicalizedParser LP;

   public SNLPModel()
   {
      // Using a relative file path in the target build directory
      LP = LexicalizedParser.loadModel("models-stanford\\englishPCFG.ser.gz");
   }
}
Run Code Online (Sandbox Code Playgroud)

但是当我将"englishPCFG.ser.gz"文件设置为visual studio中的嵌入式资源(使用VS2012)时,更改代码以匹配:

public class SNLPModel
{
   public LexicalizedParser LP;

   public SNLPModel()
   {
        // Using this line of code to verify that the file is being loaded as
        // an embedded resource. Running in debug, I have verified that it is, and
        // noted its complete name.
        string[] s = System.Reflection.Assembly.GetExecutingAssembly() …
Run Code Online (Sandbox Code Playgroud)

c# ikvm visual-studio-2012

6
推荐指数
1
解决办法
1199
查看次数

标签 统计

c# ×1

ikvm ×1

visual-studio-2012 ×1