basic serialization fails in outlook add-in

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

basic serialization fails in outlook add-in
 
Daniel McPherson




Posts: 15
Joined: 2005-03-23
Hi Sergey,

Apologies, should have included full code. I'm not trying to serialise the full addin, but instead a custom class, and in VB. It used to work, and I suspect it broke with the latest add-in build.

Here it is in full:

Imports System.Xml.Serialization
Imports System.IO
Imports System.Windows.Forms
Imports NiftySoftware.OutlookTools

<Serializable(), XmlRootAttribute("NiftyMailManager", Namespace:="http://www.niftysoftware.com", IsNullable:=False)> _
Public Class nmConfiguration

Private Const configFileName As String = "\nmConfig.xml"
Private _mailHomeFolder As MailFolder
Private _mailArchiveFolder As MailFolder
Private _fileHomeFolder As String
Private _fileArchiveFolder As String
Private _mailMiscFolder As MailFolder
Private _fileMiscFolder As String
Private _userPrefix As String

Sub New()
_mailHomeFolder = New MailFolder
_mailArchiveFolder = New MailFolder
_mailMiscFolder = New MailFolder
End Sub

Public Event MailFolderUpdate(ByVal newFolder As MailFolder, ByVal mailFolder As String)

Public Property UserPrefix() As String
Get
Return _userPrefix
End Get
Set(ByVal Value As String)
_userPrefix = Value
End Set
End Property

Public Property MailHomeFolder() As MailFolder
Get
Return _mailHomeFolder
End Get
Set(ByVal Value As MailFolder)
_mailHomeFolder = Value
RaiseEvent MailFolderUpdate(_mailHomeFolder, nmConstants.MAIL_HOME_FOLDER)
End Set
End Property

Public Property MailArchiveFolder() As MailFolder
Get
Return _mailArchiveFolder
End Get
Set(ByVal Value As MailFolder)
_mailArchiveFolder = Value
RaiseEvent MailFolderUpdate(_mailArchiveFolder, nmConstants.MAIL_ARCHIVE_FOLDER)
End Set
End Property

Public Property MailMiscFolder() As MailFolder
Get
Return _mailMiscFolder
End Get
Set(ByVal Value As MailFolder)
_mailMiscFolder = Value
RaiseEvent MailFolderUpdate(_mailMiscFolder, nmConstants.MAIL_MISC_FOLDER)
End Set
End Property

Public Property FileHomeFolder() As String
Get
Return _fileHomeFolder
End Get
Set(ByVal Value As String)
_fileHomeFolder = Value
End Set
End Property

Public Property FileArchiveFolder() As String
Get
Return _fileArchiveFolder
End Get
Set(ByVal Value As String)
_fileArchiveFolder = Value
End Set
End Property

Public Property FileMiscFolder() As String
Get
Return _fileMiscFolder
End Get
Set(ByVal Value As String)
_fileMiscFolder = Value
End Set
End Property

Public Shared Function GetSettings() As nmConfiguration
Try
Dim config As nmConfiguration
Dim Serializer As New XmlSerializer(GetType(nmConfiguration))
Dim Reader As New StreamReader(GetConfigPath() & configFileName)
config = CType(Serializer.Deserialize(Reader), nmConfiguration)
Reader.Close()
Return config
Catch noConfig As System.IO.FileNotFoundException
Catch noConfig As System.IO.DirectoryNotFoundException
Catch ex As Exception
MsgBox("Load: " & ex.Message & " " & ex.InnerException.ToString)
End Try
End Function

Public Shared Function GetConfigPath() As String
Dim pathSegments() As String
Dim localSettingsPath As Uri
Dim cmConfigPath As String
Dim x As Integer

pathSegments = Split(Application.UserAppDataPath, "\")

For x = pathSegments.GetLowerBound(0) To 3
cmConfigPath = cmConfigPath & pathSegments(x) & "\"
Next

cmConfigPath = cmConfigPath & "Nifty Software\Nifty Mail Manager"

Return cmConfigPath
End Function

Public Function Save() As Boolean
Dim configPath As String
Dim dirTool As IO.Directory

configPath = GetConfigPath()
dirTool.CreateDirectory(configPath)

Try
Dim Serializer As New XmlSerializer(GetType(nmConfiguration))
Dim Writer As New StreamWriter(configPath & configFileName)
Serializer.Serialize(Writer, Me)
Writer.Close()
Catch ex As Exception
MsgBox("Save: " & ex.ToString)
Return False
End Try

Return True

End Function
End Class
Posted 28 Mar, 2005 14:47:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Daniel.

Thanks for the code. I will test out your code and will let you know about results a bit later.
Posted 29 Mar, 2005 06:37:53 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Daniel, is the MailFolder serializable type? I can't reproduce the error because I haven't the NiftySoftware.OutlookTools assembly.
Posted 29 Mar, 2005 17:33:07 Top
Daniel McPherson




Posts: 15
Joined: 2005-03-23
Here is the MailFolder class...

Did something change in yur addin to impact Serialisation?

Thanks,
Daniel

<Serializable()> _
Public Class MailFolder

Private _folderID As String
Private _folderPath As String

Sub New()

End Sub

Sub New(ByVal FolderPath As String, ByVal FolderID As String)
_folderID = FolderID
_folderPath = FolderPath
End Sub

Public Property FolderID() As String
Get
Return _folderID
End Get
Set(ByVal Value As String)
_folderID = Value
End Set
End Property

Public Property FolderPath() As String
Get
Return (_folderPath)
End Get
Set(ByVal Value As String)
_folderPath = Value
End Set
End Property
End Class
Posted 30 Mar, 2005 07:00:23 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Daniel.

Thanks for the code. I have just tested it and all works fine.
I haven't got any error messages. I use the lates ADX build.
Posted 30 Mar, 2005 07:52:43 Top
Daniel McPherson




Posts: 15
Joined: 2005-03-23
OK, thanks. My wonder is why it works when I copy the DLL's into the Outlook folder, but doesn't work when they are in their own folder?

This used to work, and the only change I can think of is the ADX Upgrade. What is the latest build?

Daniel
Posted 30 Mar, 2005 08:23:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
The latest build is 2.2.1750
Daniel, are the NiftySoftware.OutlookTools assembly and add-in assembly placed in the same folder?
Posted 30 Mar, 2005 08:46:39 Top
Daniel McPherson




Posts: 15
Joined: 2005-03-23
Yes they are. They were both in an application folder (Broken), then I moved them both to the Outlook folder (works).
Posted 30 Mar, 2005 08:56:20 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Daniel,
are you able to debug your project? Could you tell me where exactly do you get the error? I tested out the code you gave me and all works properly. However I didn't see the whole your project. Probably it has some specific features. Anyway it would be great to get the original source code.
Posted 30 Mar, 2005 14:54:59 Top
Daniel McPherson




Posts: 15
Joined: 2005-03-23
Hey Sergey,

I found out what was causing the problem, it seems to be some sort of conflict between the latest build of IntraVnews (another outlook addin, RSS Reader) and my addin.

Not sure if it's a problem with Add-In Express or IntraVnews. That said, I dont think IntraVnews caused the problem.

You able to try installing this:
http://www.intravnews.com/beta/intravnews1.12.1873.4388.msi

And then checking to see if you get the issue? Maybe you can see what it causing the problem.
Posted 31 Mar, 2005 16:11:01 Top