2012-04-05 81 views
1

我在C#语言中使用opennlp工具。 我写了下面的代码:TypeInitializationException未处理

string modelpath = @"D:\models\en-sent.bin"; 
java.io.FileInputStream modelInpStream = new java.io.FileInputStream(modelpath); 
SentenceModel model = new SentenceModel(modelInpStream); 
SentenceDetectorME sentenceDetector = new SentenceDetectorME(model); 

,但它造成的线TypeInitializationException:

SentenceModel model = new SentenceModel(modelInpStream); 

异常消息:

TypeInitializationException was unhandled 
The type initializer for 'java.nio.charset.StandardCharsets' threw an exception. 
+4

嗯,这是Java不是C#?除非你真的使用SharpNLP? – Yuck 2012-04-05 15:20:25

回答

0

假设你使用的IKVM代码转换openNLP jar文件到.Net,你应该只需要在你的项目中包含IKVM Charsets dll以使其工作。