"액세스 위반 예외가 처리되지 않았습니다"라는이 끔찍하고 짜증나는 오류에 대한 많은 게시물을 읽었습니다. 그러나 Word2007과 "Selection.Find.Execute"명령을 올리는 것은 단 하나의 게시물입니다. 제안 된 솔루션은 Word2007을 다시 설치하는 것이 었으며 조금 사소했습니다!Word2007 : Selection.Find.Execute를 실행할 때 액세스 위반 예외가 처리되지 않았습니다.
제 환경을 설명하려고합니다.
WinForms를 사용하고 InteropServices (word.dll)를 통해 Word를 호출하여 Word2007 인스턴스를 올리는 새 문서를 만드는 C#으로 작성된 작은 응용 프로그램이 있습니다. 모든 코드는 .NET Framework 3.5에서 실행됩니다. C# 코드에서 문서를 만든 다음 그 문서에서 대체 할 내용을 검색합니다.
일부 컴퓨터에서만 프로그램이 오류를 발생시키는 반면 다른 컴퓨터에서는 올바르게 실행됩니다. . 코드가 메시지 "보호 된 메모리를 읽거나 쓰려고 시도로"액세스 위반 "예외가 발생 굵게 라인을 실행하면 이것은 다른 메모리가 표시 종종
WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
WordApp.Visible = false;
...
this.copDoc = WordApp.Documents.Add(ref template,
ref missing,
ref missing,
ref isVisible);
this.copDoc.Activate();
...
WordApp.Selection.Find.Execute(ref textData, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
if (WordApp.Selection.Find.Found)
{
Range r = WordApp.Selection.Range;
r.Text = DateTime.Today.ToLongDateString();
}
...
입니다
:
이
은 코드 조각입니다 부패하다. " 이 코드에 주석을 달면 문서가 만들어 졌으므로이 예외는 전체 단어에만 관련이있는 것이 아니라 일부 특수 구성에서만 관련된다는 의미 일 수 있습니다.'EdAg.exe': Loaded 'C:\Windows\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll', Binary was not built with debug information.
'EdAg.exe' (Managed): Loaded 'C:\Windows\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll'
First-chance exception at 0x45c7a6f3 in EdAg.exe: 0xC0000005: Access violation.
First-chance exception at 0x6b815095 in EdAg.exe: 0xC0000005: Access violation reading location 0x45c7a6f3.
First-chance exception at 0x6b815095 in EdAg.exe: 0xC0000005: Access violation reading location 0x45c7a6f3.
누군가가 나에게 대신 2,007 말씀을 다시 설치하는보다 합리적인 방법을 제안 할 수 없습니다 : 여기
은 예외?
당신의 솔루션은 매우 흥미 롭습니다.하지만 지금은 이미 Word 2007 설치 문제를 해결했습니다. 나는 당신이 나에게 미래에 대해 말해 준 해결책을 얻을 것이다. 감사 – robob