을 쓰려고 시도 Windows Vista 또는 Windows 작업 7System.AccessViolationException가 : 읽거나 내가 Word 2007에서 "찾기 및 바꾸기"할 때 보호 된 메모리를 나는 다음과 같은 예외가
System.AccessViolationException : 보호 된 메모리를 읽거나 쓰려고 시도했습니다. 메모리. 이것은 종종 다른 메모리가 손상되었다는 표시 인 입니다. 에서 Microsoft.Office.Interop.Word.Find.Execute (& MatchSoundsLike 객체, & MatchWildcards 객체, & MatchWholeWord 객체, & MatchCase 객체, & 에는 FindText 객체 & MatchAllWordForms 객체, & 앞으로, Object입니다 & 랩,개체, & MatchKashida 개체, & 바꾸기 객체, & 형식 객체 & ReplaceWith 객체 0 MatchDiacritics, 객체 &이 MatchAlefHamza, & MatchControl 객체)
이에 대한 모든 솔루션이 있습니까?
Iam using .NET3.5 C#.
********** CODE ****************는
public static Application Open(string fileName)
{
object fileNameAsObject = (object)fileName;
Application wordApplication;
wordApplication = new Application();
object readnly = false;
object missing = System.Reflection.Missing.Value;
wordApplication.Documents.Open(
ref fileNameAsObject, ref missing, ref readnly,
ref missing,ref missing, ref missing, ref missing,
ref missing,ref missing, ref missing, ref missing,
ref missing,ref missing, ref missing, ref missing,
ref missing
);
return wordApplication;
}
private static void ReplaceObject(
ref Application wordApplication,
object ObjectTobeReplaced, object NewObject)
{
// ++++++++Find Replace options Starts++++++
object findtext = ObjectTobeReplaced;
object findreplacement = NewObject;
object findforward = true;
object findformat = false;
object findwrap = WdFindWrap.wdFindContinue;
object findmatchcase = false;
object findmatchwholeword = false;
object findmatchwildcards = false;
object findmatchsoundslike = false;
object findmatchallwordforms = false;
object replace = 2; //find = 1; replace = 2
object nevim = false;
Range range = wordApplication.ActiveDocument.Content;
range.Find.Execute(
ref findtext, ref findmatchcase, ref findmatchwholeword,
ref findmatchwildcards,ref findmatchsoundslike,
ref findmatchallwordforms, ref findforward, ref findwrap,
ref findformat, ref findreplacement, ref replace,
ref nevim, ref nevim, ref nevim, ref nevim
);