public class word
{
public long high;
public long low;
public float sig;
public word next;
} public const int MAX_WORD_LEN_E_K = 20;
public class keyword
{
public char[] word = new char[MAX_WORD_LEN_E_K];
public int weight;
public keyword next;
} public class forbidword
{
public char[] word = new char[MAX_WORD_LEN_E_K];
public forbidword next;
}
[DllImport("readdic.dll", EntryPoint = "read_forbid_dic")]
static extern int readforbiddic(string dicfilepath, forbidword forbid_dic_head); [DllImport("readdic.dll", EntryPoint = "read_keyword_dic")]
static extern int readkeyworddic(string dicfilepath, keyword keyword_dic_head); [DllImport("summary_e.dll", EntryPoint = "_english_entry_summary")]
static extern string entry(string document, int summary_size, forbidword forbid_dic_head, keyword keyword_dic_head); string forbid_dic_path = "forbid_dic.txt";
string keyword_dic_path = "keyword_dic.txt";
string summary;
forbidword forbid_dic_head = new forbidword();
keyword keyword_dic_head = new keyword();
private void 开始_Click(object sender, EventArgs e)
{
forbid_dic_head.next = null;
keyword_dic_head.next = null; if (readforbiddic(forbid_dic_path, forbid_dic_head) == -1)
{
MessageBox.Show("read forbid dic error!");
return;
}
else
if (readkeyworddic(keyword_dic_path, keyword_dic_head) == -1) {
MessageBox.Show("read keyword dic error!");
return;
}
else
{
StreamReader TxtReader = new StreamReader("1.txt", System.Text.Encoding.GetEncoding("gb2312"));
summary = entry(TxtReader.ReadToEnd(), 512, forbid_dic_head, keyword_dic_head);
MessageBox.Show(summary);
}
}红色加粗代码报错:Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
{
public long high;
public long low;
public float sig;
public word next;
} public const int MAX_WORD_LEN_E_K = 20;
public class keyword
{
public char[] word = new char[MAX_WORD_LEN_E_K];
public int weight;
public keyword next;
} public class forbidword
{
public char[] word = new char[MAX_WORD_LEN_E_K];
public forbidword next;
}
[DllImport("readdic.dll", EntryPoint = "read_forbid_dic")]
static extern int readforbiddic(string dicfilepath, forbidword forbid_dic_head); [DllImport("readdic.dll", EntryPoint = "read_keyword_dic")]
static extern int readkeyworddic(string dicfilepath, keyword keyword_dic_head); [DllImport("summary_e.dll", EntryPoint = "_english_entry_summary")]
static extern string entry(string document, int summary_size, forbidword forbid_dic_head, keyword keyword_dic_head); string forbid_dic_path = "forbid_dic.txt";
string keyword_dic_path = "keyword_dic.txt";
string summary;
forbidword forbid_dic_head = new forbidword();
keyword keyword_dic_head = new keyword();
private void 开始_Click(object sender, EventArgs e)
{
forbid_dic_head.next = null;
keyword_dic_head.next = null; if (readforbiddic(forbid_dic_path, forbid_dic_head) == -1)
{
MessageBox.Show("read forbid dic error!");
return;
}
else
if (readkeyworddic(keyword_dic_path, keyword_dic_head) == -1) {
MessageBox.Show("read keyword dic error!");
return;
}
else
{
StreamReader TxtReader = new StreamReader("1.txt", System.Text.Encoding.GetEncoding("gb2312"));
summary = entry(TxtReader.ReadToEnd(), 512, forbid_dic_head, keyword_dic_head);
MessageBox.Show(summary);
}
}红色加粗代码报错:Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
debug时:报如上错误
release时:readforbiddic(forbid_dic_path, forbid_dic_head) == -1,弹出对话框“read forbid dic error!”