Attempted to read or write protected memory....

B

Badis

Hi,

I'm using automation to produce word documents, and it's working fine in my
machine that have vs.net 2005 and office xp in it. BUT when I move my
application to another machine that have vs.net 2005 express edition with
office 97 I'm getting this error:
"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."

when it comes to the second line of this code :
wrdApp = new Word.Application();
// Add a new document.
wrdDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref oMissing, ref
Missing);
Do I have to upgrade the vs.net 2005 express edition to vs.net 2005 and
word97 to xp to make it work or is it some thing else!?

Cheers.
 
C

Cindy M.

Hi =?Utf-8?B?QmFkaXM=?=,

You appear to be using C#. C# is very strict about typing and method
signatures. The Office object models are structured on the old Visual Basic
rules. Among other things, these support optional method parameters. C# can't
work with optional parameters.

If you look at the Documents.Add method for Word 97 and compare it to that of
Word 2002, you'll probably see that Word 97 has a different method signature
(fewer parameters). So, as it stands, the code developed for Word 2002 cannot
run against Word 97.
I'm using automation to produce word documents, and it's working fine in my
machine that have vs.net 2005 and office xp in it. BUT when I move my
application to another machine that have vs.net 2005 express edition with
office 97 I'm getting this error:
"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."

when it comes to the second line of this code :
wrdApp = new Word.Application();
// Add a new document.
wrdDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref oMissing, ref
Missing);
Do I have to upgrade the vs.net 2005 express edition to vs.net 2005 and
word97 to xp to make it work or is it some thing else!?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top