2012-04-05 77 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以使其工作。