Search This Blog

Showing posts with label Deserialization. Show all posts
Showing posts with label Deserialization. Show all posts

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.

Saturday, September 26, 2009

Fun with Deserialization

More fun serialization, this time with deserialization.

Currently working on a .net project whose feature set will allow my to replace some older third party libraries used in a VB6 project that do not work properly under Vista 64bit edition.

Things that I have successfully completed:
  • Replaced Microsoft IE6 era Web browser control with a .net webbrowser control in a winform.
  • Replaced functionality of Microsoft Internet transfer control to download online files.
  • Successfully extended Google Picasa API and Blogger API to VB6 through COM interop type library
  • Successfully implemented binary serialization of Picasa and Blogger caching the data locally.
DRCWinformUI.DLL - COM Interop assembly exposing methods/events for use in VB6 project
PicasaBloggerUserControls.DLL - .net 2.0 framework

Now to the problem: Deserialization:

Implemented code to de-serialize objects, which works fine in .net test app, but fails over COM:
SerializationException: Cannot find assembly...

Found the following articles:
Excellent article from http://spazzarama.wordpress.com/ describing the exact same problem:

C# – BinaryFormatter.Deserialize is “Unable to find assembly”


Documentation for SerializationBinder Class

I must give props to a co-worker Tom G. who pointed me in the correct direction of properly resolving the assembly by name. A problem that was solved at work on another project.