Property page not shown

Add-in Express™ Support Service
That's what is more important than anything else

Property page not shown
 
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Hi!

I have a little problem with property pages in Outlook 2000/2003
I created a shimed C#-COM-AddIn with a property page shown in outlook (no specific folder).
Further i created a Setup-Project following the instructions in VSSetup.doc
(set the register property of my AddIn to vsdrpCOM)

If i install my project on the dev machine or another machine and open Outlook my property page isn't shown.
Otherwise if i use 'Register ADX Project' on my dev machine i can see the property page. What do i'm wrong ?

I'm using ADX.Net 2.6, VS2003
The ProgId of my property page is set right in my AddinModule
My Com-Addin is not disabled in Outlook 2003 and will be loaded at startup
No error message appears in outlook.

Thanx for your help!

Ciao,
Thomas
Posted 11 Jul, 2006 07:33:15 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Thomas.

Do you get any error messages?
Posted 11 Jul, 2006 08:14:27 Top
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Hi Sergey!

First thanx for your really fast reply!!! :-)

No error message appears while opening outlook.
I can see the property page if i register the ADX project from inside VS2003
But if i install the addin with the installer i cannot see the property page.


Ciao,
Thomas
Posted 11 Jul, 2006 08:19:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Thomas, please test the OutlookPropertyPage ADX example. Does it work on your PC?
Posted 11 Jul, 2006 08:43:37 Top
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Hi Sergey!

I tested the ADX Outlook Property Pagwe example without success..:-(
It didn't work for me. Same behaviour as described above.
If i create a setup and install the addin via setup i cannot see any property page. If a use Register ADX project from within VS2003 it works like a charme.

I must change some path issues in your ADX example project to get it to work,
but i think ididn't something wrong.


Ciao,
Thomas
Posted 11 Jul, 2006 09:09:32 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Thomas, I can send you a test by email in several minutes.
Could you please test it on your PC?
Posted 11 Jul, 2006 09:34:05 Top
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Yes that would be fine....

Thanx Sergey!
Posted 11 Jul, 2006 09:34:53 Top
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Hi Sergey!

I tested your Property example you sent to me yesterday evening.
First i didn't work then it does after i deinstalled my project.

No my Addin shows the property page correctly.
After some debugging i found the guilty method:

In my AddinModule_AddinStartupComplete a method will be called that checks if a custom form exists and if not installs it under the default appointment folder. However if i commented aout this method the property page was shown.

Here is the method:

		private void publishCustomForm()
		{
			Outlook._Application myOlApp = null;
			Outlook._NameSpace olNs = null;
			Outlook.MAPIFolder CalendarFolder = null;
			Outlook._Items calItems = null;
			Outlook._AppointmentItem myItem = null;
			Outlook.FormDescription myForm = null;

			string filename = string.Empty;
			string strTemp = string.Empty;
			int endpos;
			int mylength;

			try
			{
				myOlApp = OutlookHost();
				olNs = myOlApp.GetNamespace("MAPI");
				CalendarFolder = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

				//retrieve Outlook Templates
				System.Reflection.Assembly Asm = System.Reflection.Assembly.GetExecutingAssembly();
				filename = System.IO.Path.GetDirectoryName(Asm.Location) +	@"my_form.oft";

				if( filename != "")
				{
					mylength = filename.Length;

					//strip off the extension from the filename.
					endpos = filename.IndexOf(".oft");
					strTemp = filename.Substring(0, endpos).Trim();					
					
					calItems = CalendarFolder.Items;
					myItem = (Outlook._AppointmentItem)calItems.Add("IPM.Appointment.R1");

					if(myItem.FormDescription.Name == null)
					{
						MessageBox.Show("[Debug]: No custom form found...Installing a new one");
						//publish all Outlook forms into folder Registry
						myItem = (Outlook.AppointmentItem)myOlApp.CreateItemFromTemplate(filename, CalendarFolder);
						myForm = myItem.FormDescription;

						myForm.Name = "R1";
						myForm.DisplayName = "Raumbuchung";
						myForm.PublishForm(Outlook.OlFormRegistry.olFolderRegistry, CalendarFolder);
						
						myItem.Close(Outlook.OlInspectorClose.olDiscard);
					}
					else
					{
						MessageBox.Show("[Debug]: The following custom form could be found: "+myItem.FormDescription.Name);
					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
			finally
			{
				myOlApp = null;
				olNs = null;
				CalendarFolder = null;
				myItem = null;
				calItems = null;
				myForm = null;

//				if(myItem != null)
//					Marshal.ReleaseComObject(myItem);
//				if(calItems != null)
//					Marshal.ReleaseComObject(calItems);
//				if(myForm != null)
//					Marshal.ReleaseComObject(myForm);
//
//				if(myOlApp != null)
//					Marshal.ReleaseComObject(myOlApp);
//				if(olNs != null)
//					Marshal.ReleaseComObject(olNs);
//				if(CalendarFolder != null)	
//				    Marshal.ReleaseComObject(CalendarFolder);
			}		
		}


I encountered the following problem: if i use Marshal.ReleaseComObject(...) to derefrence my used objects the property page would not been shown. Setting the references simply to null seems to work correctly.

When should i use Marshal.ReleaseComObject(...) and when not?

Thanx for your help!!!!

Ciao,
Thomas
Posted 12 Jul, 2006 04:38:41 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Thomas.

You shouldn't use the Marshal.ReleaseComObject method with the Outlook application object (myOlApp).
Just remove the 'Marshal.ReleaseComObject(myOlApp)' code.
Posted 12 Jul, 2006 07:38:07 Top
Thomas Guenther




Posts: 94
Joined: 2006-02-20
Hi Sergey!

Ok. i removed it. Since im a newby to COM development i missed some basics :-|

I find it very hard to decide when to use Marshal.ReleaseComObject(...) and when not....


THANX for your help! Your da best !!!!!


Ciao,
Thomas
Posted 12 Jul, 2006 07:42:57 Top