MEF null-ref Exception importing Log

Jul 1, 2010 at 10:11 PM
Edited Jul 6, 2010 at 5:23 PM

After trying out MSAF in a sample project successfully, I'm starting to utilize and integrate it into large existing SL4 project. I simply copied over one TrackAction on a button of one page in the xaml. All the needed references are added. All appears correct, and compiles successfully, but I'm seeing the following exception on InitializeComponent of the Page. Any suggestions you can provide are much appreciated.

The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) Object reference not set to an instance of an object. Resulting in: An exception occurred while trying to create an instance of type 'Microsoft.WebAnalytics.DataCollector'. Resulting in: Cannot activate part 'Microsoft.WebAnalytics.DataCollector'. Element: Microsoft.WebAnalytics.DataCollector --> Microsoft.WebAnalytics.DataCollector --> AssemblyCatalog (Assembly="Microsoft.WebAnalytics, Version=1.0.2.0, Culture=neutral, PublicKeyToken=7a32084d620a2a02") Resulting in: Cannot get export 'Microsoft.WebAnalytics.DataCollector.Log (ContractName="Log")' from part 'Microsoft.WebAnalytics.DataCollector'. Element: Microsoft.WebAnalytics.DataCollector.Log (ContractName="Log") --> Microsoft.WebAnalytics.DataCollector --> AssemblyCatalog (Assembly="Microsoft.WebAnalytics, Version=1.0.2.0, Culture=neutral, PublicKeyToken=7a32084d620a2a02") Resulting in: Cannot set import 'Microsoft.WebAnalytics.Behaviors.TrackAction.Log (ContractName="Log")' on part 'Microsoft.WebAnalytics.Behaviors.TrackAction'. Element: Microsoft.WebAnalytics.Behaviors.TrackAction.Log (ContractName="Log") --> Microsoft.WebAnalytics.Behaviors.TrackActi

Jul 6, 2010 at 5:24 PM

I found the root cause of this exception.  The DataCollector class requires there to be an AssemblyTitle.  The project this code was getting packaged into did not have an AssemblyInfo.cs file.   Once I added that file with an AssemblyTitle, the exception in the DataCollector constructor did not occur.