我在 c#.net 中使用 nHapi 使用以下代码将 hl7 消息转换为 xml 格式。我的代码:
using System;
using NuGet;
using NHapi.Model;
using NHapi.Model.V231;
using NHapi.Model.V231.Message;
using NHapi.Base.Parser;
using NHapi.Base.Model;
namespace HL7parser
{
class Program
{
static void Main(string[] args)
{
String msg =
"MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A01||P|2.2\r........."
PipeParser parser = new PipeParser();
try {
IMessage mssg =parser.Parse(msg);
XMLParser xMLParser=null;
String str=xMLParser.Encode(mssg);
Console.WriteLine(str);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.GetType().Name);
Console.WriteLine(e.StackTrace);
}
Console.WriteLine("\n Press Enter to continue...");
Console.Read();
}}}
现在它显示:
The type initializer for 'NHapi.Base.PackageManager' threw an exception.
TypeInitializationException
at NHapi.Base.Parser.ParserBase.Parse(String message)
at HL7parser.Program.Main(String[] args) in C:\Users\Administrator\source\repos\HL7parser\HL7parser\Program.cs:line 28
谁能告诉我为什么?这到底有什么问题?