Search This Blog

Tuesday, October 6, 2009

Deserialization Problem solved!

I have been working on COM interop project to allow access to Google Blogger and Picasa API from a Visual Basic 6.0 App. I know I know, why let go of the past and write a modern app perhaps in WPF..., I have my reasons.

Blogger Solution
COM Interop Project
Google API Project
Test UI Project

VB6 Project
Referencing COM Interop type Library

My solution is written in C#, 2.0 Framework (trying to still support Windows 2000, again I know I know let go of the past...) Added a Test windform project to the solution so I can run UI tests without COM. Worked great!

Created my COM interop project, something I had not done before. It seemed to work fine.

Then I decided I needed to serialize objects to cache downloaded album and images to spend up locating an online image. Worked well in C# except, when deserializing objects kept throwing errors when run from COM from my VB6 project. Two errors, Unable to find file (Assembly DLL) and unable to load type. Puzzled, I googled for a solution, WOW what a fine mess binary deserialization can be!

After several failed attempts, I found the solution:
1) Could not run my VB6 project and get the deserialization to work. Compiled the exe and...
2) Created an App.Config and renamed after my VB6 project exe: MyProject.exe.Config
3) In the App.Config, In the runtime section, I added for each of assemblies.

Now I can run my COM Interop project from VB6 and deserialization does not throw errors. At some point I am going to try to actually understand why this works but right now my goal is simply a working pattern that I can successfully produce.

Key my solution came when I enabled Fusion logging so I could see why was happening as my code loaded or tried to load assemblies needed for deserialization.

No comments: