Progger100

In my c# application a lot of interop code is used, a.o. with Word etc.

This works fine, but I have noticed a conciderable slow down of this interop code with Word on some computers (even very powerful pc's, without any other program running !).

First I saw this only in combinations of Word 2000 on Windows XP. It also occurs with newer versions of Word and Windows, but less frequently.

On several new and very fast computers, interacting with Word from the c# application is extremely slow, even with the simplest code.

I.e. :

Word.Application app = new Word.Application();

for(int i = 0; i < 100; i++)

{

app.visible = !app.visible;

}

If I install Office 2002 (XP) or later on our development machine, this code takes some seconds to execute.

If I de-install Office 2002 and reinstall Office 2000, the code works but takes easily 15 TIMES as long to complete !

This happens for all interop code, with the same slow-down-factor as I would call it, roughly 15 times longer then normal.

I've tried late binding with no difference.

If you just work in Word on these pc's (writing a document manually), there's no difference in speed between pc's that are fast or slow in interop, so it's not that Office is not correctly installed or something.

I have noticed this problem om a lot of computers. The solution is sometimes to upgrade to Office XP or later, but this is not an option for some customers.

Did anyone experience the same problems Does anyone have a solution for this problem



Re: Common Language Runtime Slow interop with Word in c# application

Feng Chen - MSFT

Hi Progger,

On the computer with this problem, have you installed the Office PIA of correct version

Thanks!






Re: Common Language Runtime Slow interop with Word in c# application

Progger100

Hello,

Thanks for your answer.

For office 2000, there is no PIA. For the newer office versions, installing or de-intalling PIA's does not make a difference in speed.

It has no link to virus scanning software either.

Until now I only found 1 reference to this problem, from 2004, without any solution.

http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.interop/2004-12/0260.html

The problem persists, it is only if you really use a lot of interop code that this becomes very clear.

What I try to focus on, is the fact that on the same PC, installing Office XP makes the interop code fast, but after de-installing it and installing Office 2000, everything becomes terribly slow again, while just working in Word itself is not slower or faster.

It's as if the COM calls have something extra to check before being executed, like the calls are waiting in a queue and suddenly performing slower, because each time some same basic "link" or index has to be found again.

My only guess is this has something to do with missing references in the registry; but then again, this does not explain why the same combination of Windows and Office sometimes performs slowly and sometimes very fast.

It should be helpfull if I could control or check the COM call process in more detail, how is it done, what does windows or the dotnet framework do behind the scenes, is it possible to interact with Windows/dotnet framework in any way to make the COM call faster or slower. Right now there's nothing I can do to improve performance except upgrading from Office 2000 to Office XP, which is not always a solution but most of the times it is.

Sorry for the not so clear explanation, I'm really out of options at this moment.





Re: Common Language Runtime Slow interop with Word in c# application

stephen anzaldua

i've found that the only way to speed up an affected computer is to uninstall service pack 2 for win XP. after rebooting, the automations with word 2000 are way faster than before, but when you attempt to reinstall SP2, they go right back to a sluggish mess. what differences between SP1 and SP2 could cause this also. it seems that only dual processor computers are affected






Re: Common Language Runtime Slow interop with Word in c# application

Progger100

Hello Stephen,

indeed, it's only brand-new pc's with dual processors that are affected, glad you also noticed that, I had some suspicions about it but I thought this was impossible as a reason to perform slower.

That was the only difference at 1 customer's site, where they had 2 relatively new pc's, one with a dual and one with a single processor. All other things were equal, only the dual processor did have the problem.

I will try deinstalling SP2, will keep you informed.

It's only Office 2000 on a dual processor pc that always consistently performs very bad. Other combinations of Windows-Office may have the problem too, but much less frequently. (i.e. I had 1 customer with Windows XP-Office XP that had exactly the same problem, slow down by a factor 10-15, don(t know wether they have dual processor or not, will check that.)

Under Vista, performance is also down with all office versions, but most of the times not to the level that it's unworkable.

Should there be a way to treat word documents without passing by COM interop, this could be solved once and for all. We are currently looking at how Open Office reads Word documents, maybe we can read them too and treat them on a binary level. Otherwise we're stuck forever with this problem...





Re: Common Language Runtime Slow interop with Word in c# application

stephen anzaldua

i'll continue testing and keep you posted






Re: Common Language Runtime Slow interop with Word in c# application

Ghinx

I too also got this same problem with some clients. Indeed its the Dual Core and Office 2000 combination thats causing it. There is no easy way around it. Through my testings i found that if you disable one of the processors through BIOS, it will fix it self. Its probably the way Office 2000 interacts with Dual Cores (Incompatibility ). I doubt Microsoft will fix this as 2000 is already tooooooooooooooooooo old.



Re: Common Language Runtime Slow interop with Word in c# application

stephen anzaldua

hehe, so our options so far are the admins' inconvenience or the users' inconvenience. i've picked the latter over the former and tripled their RAM. Surprise)





Re: Common Language Runtime Slow interop with Word in c# application

Andreas Åhlin

I have also had this problem and can confirm its seems to be only newer processors that are affected.

I had problem with a HP dc7600 Small Form Factory PC.

I "solved" the problem by adding the switch /ONECPU in boot.ini

I will run this sollution for a week or two and see if the computer runs slower than before using the switch.

Regards

Andreas Ahlin