Outlook 2007 Add-in Bug with with Exchange - Long explanation

Status
Not open for further replies.
Q

QW5kcmV3

Hello Folks: This is a strange issue which needs a long explanation!

We have an Outlook 2007 add-in written in VB.Net, which on load of Outlook

loops through all the contacts adds a property if all the criterias are met

and then closes the contact. We tested this on multiple machines with over

2000 contacts and though it took significantly longer to complete, it did not

break.

When the add-in was loaded on an Outlook install with over 1000 contacts,

that worked with exchange however, after looping through 242 contacts it

threw an error which said that "the systems administrator had limited the

amount of items that can be opened simultaneously, and that we needed to

close some items in order to get it function properly." After that error, the

calendar view broke and wasn't displaying properly and multiple other things

did not function properly.

I am closing each contact by running this line of code so that I know its

was closed by the add-in "oContact.Close(Outlook.OlInspectorClose.olSave)"

and setting "oContact = Nothing" just to be safe. That still didn't fix the

problem.

To get an idea as to what exactly was running, I added code to write to a

text file the count of each contact that was opened and closed. This I added

at the end of the loop and in a "Catch" in the event it threw the error. This

allowed me to see it was breaking after the 243 'rd contact.

So by luck I added another line in the loop which wrote to the log file.

Adding this "fixed" the problem because it successfully completed the loop

and everything worked fine on load of Outlook. The log file showed it looped

through the 1003 contacts the user had.

This user was did not have the "Cached Exchange Mode" checkbox set. When it

was set, there was no problem at all even without writing to the log file.

When it was not using the Cached Exchange Mode, it broke. My theory is that

even though I'm closing the contact, Outlook still has it open or has a

reference to it because it needs to update the information on the Exchange

Server. Hence the reason it thinks the contacts are still opened. Somehow,

the extra time needed to write to the text file gave it enough time to update

the exchange server and properly close the contact.

I hope I provided enough information to get a proper idea as to what's going

on.

Does anyone know exactly what's going on, so that I can have a proper fix

for this issue.

Regards,
 
That sounds like the RPC channel problem.

When used with Exchange there's a usual limit of roughly 255 open RPC

channels, set by a registry setting on the server. When that limit is

exhausted you see problems like those you are seeing. This is not a problem

with PST files, or usually with cached mode because that's writing locally

to the OST file and the data gets written back to the server only when the

OST is synched with the server-side mailbox.

In a loop, setting an object to Nothing will release the object, but not

necessarily release the RPC channel until the garbage collector runs. That

can be a while. So your workaround with the log probably provides enough

time (by accident) for the garbage collector to run.

Outlook will open internal object instances for every dot operator you use,

so you have to be careful with those usages since those objects won't be

released until the procedure ends. The fix for that is to explicitly declare

all objects and not to let Outlook create them for you. For example, instead

of this:

Dim value As String = folder.Items.Item(1).Body

You should use something like this:

Dim colItems As Outlook.Items = folder.Items

Dim oContact As Outlook.ContactItem = colItems.Item(1)

Dim value As String = oContact.Body

That way you can explicitly release your intermediate objects.

Also of course your contact item oContact should be declared outside the

loop, along with other objects so that you aren't creating new objects in

each loop pass, but just setting an existing object. And you should set each

object you use in the loop to Nothing in each pass through the loop.

If that isn't enough, you can also call the garbage collector on each pass

through the loop, and call WaitForPendingFinalizers. You may also need to

call Marshal.ReleaseComObject on your objects on each pass, before calling

to GC.Collect and GC.WaitForPendingFinalizers.

"Andrew" <Andrew> wrote in message

news:4A17CA20-3E28-4CA4-8313-C435E392FF3F@microsoft.com...
> Hello Folks: This is a strange issue which needs a long explanation!

> We have an Outlook 2007 add-in written in VB.Net, which on load of Outlook
> loops through all the contacts adds a property if all the criterias are
> met
> and then closes the contact. We tested this on multiple machines with over
> 2000 contacts and though it took significantly longer to complete, it did
> not
> break.

> When the add-in was loaded on an Outlook install with over 1000 contacts,
> that worked with exchange however, after looping through 242 contacts it
> threw an error which said that "the systems administrator had limited the
> amount of items that can be opened simultaneously, and that we needed to
> close some items in order to get it function properly." After that error,
> the
> calendar view broke and wasn't displaying properly and multiple other
> things
> did not function properly.

> I am closing each contact by running this line of code so that I know its
> was closed by the add-in "oContact.Close(Outlook.OlInspectorClose.olSave)"
> and setting "oContact = Nothing" just to be safe. That still didn't fix
> the
> problem.

> To get an idea as to what exactly was running, I added code to write to a
> text file the count of each contact that was opened and closed. This I
> added
> at the end of the loop and in a "Catch" in the event it threw the error.
> This
> allowed me to see it was breaking after the 243 'rd contact.

> So by luck I added another line in the loop which wrote to the log file.
> Adding this "fixed" the problem because it successfully completed the loop
> and everything worked fine on load of Outlook. The log file showed it
> looped
> through the 1003 contacts the user had.

> This user was did not have the "Cached Exchange Mode" checkbox set. When
> it
> was set, there was no problem at all even without writing to the log file.

> When it was not using the Cached Exchange Mode, it broke. My theory is
> that
> even though I'm closing the contact, Outlook still has it open or has a
> reference to it because it needs to update the information on the Exchange
> Server. Hence the reason it thinks the contacts are still opened. Somehow,
> the extra time needed to write to the text file gave it enough time to
> update
> the exchange server and properly close the contact.

> I hope I provided enough information to get a proper idea as to what's
> going
> on.

> Does anyone know exactly what's going on, so that I can have a proper fix
> for this issue.

> Regards,
 
Hello Ken,

Thanks again, for the informative response/solution. All objects are

declared outside the loop, but they were not declared in the way you

suggested is best, so I'll make those changes, including the other things

you've specified and test it again to see if that fixes it.

Will post back with the results!

Regards,

Andrew
wrote:


> That sounds like the RPC channel problem.

> When used with Exchange there's a usual limit of roughly 255 open RPC
> channels, set by a registry setting on the server. When that limit is
> exhausted you see problems like those you are seeing. This is not a problem
> with PST files, or usually with cached mode because that's writing locally
> to the OST file and the data gets written back to the server only when the
> OST is synched with the server-side mailbox.

> In a loop, setting an object to Nothing will release the object, but not
> necessarily release the RPC channel until the garbage collector runs. That
> can be a while. So your workaround with the log probably provides enough
> time (by accident) for the garbage collector to run.

> Outlook will open internal object instances for every dot operator you use,
> so you have to be careful with those usages since those objects won't be
> released until the procedure ends. The fix for that is to explicitly declare
> all objects and not to let Outlook create them for you. For example, instead
> of this:

> Dim value As String = folder.Items.Item(1).Body

> You should use something like this:

> Dim colItems As Outlook.Items = folder.Items
> Dim oContact As Outlook.ContactItem = colItems.Item(1)
> Dim value As String = oContact.Body

> That way you can explicitly release your intermediate objects.

> Also of course your contact item oContact should be declared outside the
> loop, along with other objects so that you aren't creating new objects in
> each loop pass, but just setting an existing object. And you should set each
> object you use in the loop to Nothing in each pass through the loop.

> If that isn't enough, you can also call the garbage collector on each pass
> through the loop, and call WaitForPendingFinalizers. You may also need to
> call Marshal.ReleaseComObject on your objects on each pass, before calling
> to GC.Collect and GC.WaitForPendingFinalizers.

> >

>

> "Andrew" <Andrew> wrote in message
> news:4A17CA20-3E28-4CA4-8313-C435E392FF3F@microsoft.com...
> > Hello Folks: This is a strange issue which needs a long explanation!
> > We have an Outlook 2007 add-in written in VB.Net, which on load of Outlook
> > loops through all the contacts adds a property if all the criterias are
> > met
> > and then closes the contact. We tested this on multiple machines with over
> > 2000 contacts and though it took significantly longer to complete, it did
> > not
> > break.
> > When the add-in was loaded on an Outlook install with over 1000 contacts,
> > that worked with exchange however, after looping through 242 contacts it
> > threw an error which said that "the systems administrator had limited the
> > amount of items that can be opened simultaneously, and that we needed to
> > close some items in order to get it function properly." After that error,
> > the
> > calendar view broke and wasn't displaying properly and multiple other
> > things
> > did not function properly.
> > I am closing each contact by running this line of code so that I know its
> > was closed by the add-in "oContact.Close(Outlook.OlInspectorClose.olSave)"
> > and setting "oContact = Nothing" just to be safe. That still didn't fix
> > the
> > problem.
> > To get an idea as to what exactly was running, I added code to write to a
> > text file the count of each contact that was opened and closed. This I
> > added
> > at the end of the loop and in a "Catch" in the event it threw the error.
> > This
> > allowed me to see it was breaking after the 243 'rd contact.
> > So by luck I added another line in the loop which wrote to the log file.
> > Adding this "fixed" the problem because it successfully completed the loop
> > and everything worked fine on load of Outlook. The log file showed it
> > looped
> > through the 1003 contacts the user had.
> > This user was did not have the "Cached Exchange Mode" checkbox set. When
> > it
> > was set, there was no problem at all even without writing to the log file.
> > When it was not using the Cached Exchange Mode, it broke. My theory is
> > that
> > even though I'm closing the contact, Outlook still has it open or has a
> > reference to it because it needs to update the information on the Exchange
> > Server. Hence the reason it thinks the contacts are still opened. Somehow,
> > the extra time needed to write to the text file gave it enough time to
> > update
> > the exchange server and properly close the contact.
> > I hope I provided enough information to get a proper idea as to what's
> > going
> > on.
> > Does anyone know exactly what's going on, so that I can have a proper fix
> > for this issue.
> > Regards,


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
L Outlook 2007 does not start with Apple iCloud-Add-In activated Using Outlook 2
L Outlook 2007 Macro to Add Text to a Contact Field Using Outlook 10
A Not able to load an add-in for outlook 2007 developed in VSTO 2005 Outlook VBA and Custom Forms 2
A Outlook 2007 add in Outlook VBA and Custom Forms 1
S Outlook 2007 Add-in strange load behavior Outlook VBA and Custom Forms 10
A Add BCM to outlook 2007 BCM (Business Contact Manager) 1
M Will a VSTO C# Outlook 2007 Add-in work on Outlook 2010? Outlook VBA and Custom Forms 1
J how to add Business Contact Manager to existing Outlook 2007? BCM (Business Contact Manager) 2
P Setting combobox properties from Outlook 2007 Add-in Outlook VBA and Custom Forms 9
Y Outlook 2007 add-in installation problem on Vista Outlook VBA and Custom Forms 1
A COM add-in causes Outlook 2007 to periodically crash where it did not in Outlook 2003 Outlook VBA and Custom Forms 3
J No setup project with Outlook 2007 Add-In project Outlook VBA and Custom Forms 16
C Outlook 2003 Add-in doesn't work on Outlook 2007 Outlook VBA and Custom Forms 1
B Re: Outlook 2003 Add-in doesn;t work on Outlook 2007 Outlook VBA and Custom Forms 2
C Why does Outlook 2007 generate 3 events for 1 single "Add"? Outlook VBA and Custom Forms 6
D Outlook 2007 Recovering E-Mails Using Outlook 0
W Transfer Outlook 2016 autocomplete file to Outlook 2007 Using Outlook 1
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
S Outlook 2007 - Automatic purge fail Using Outlook 0
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
S Verwendung von Outlook 2007 Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
S Reboot of frozen windows7 results in changed outlook 2007 settings Using Outlook 1
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
M Configure outlook 2007 to accept digital signatures Using Outlook 2
D Outlook 2007 crashes when opening an email Using Outlook 2
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3
icacream From Outlook 2007 to 2016 ! Using Outlook 9
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S Outlook 2007: Address Cards allow entering text! Why? Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
L Outlook 2007 Separate the Send/Receive functions Using Outlook 2
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
C Move from Outlook 2007 Enterprise (MOE) to Outlook Pro plus 2007 Using Outlook 1
J reinstalling Outlook 2007 asking for user name & password Using Outlook 14

Similar threads

Back
Top