IStorageService always null?

8 views
Skip to first unread message

Biggert

unread,
Dec 9, 2011, 11:55:52 AM12/9/11
to Seesmic Desktop Platform Development
I'm using the following code in my Plugin class (which uses interface
IPlugin) which I got from this group a long time ago:

private static IStorageService _storageService;

[Import]
public IStorageService StorageServiceImport { set
{ _storageService = value; } }
public static IStorageService StorageService { get { return
_storageService; } }

In the latest version of Seesmic Desktop, when hit up
MyPlugin.StorageService, it's always null. This is causing my plugin
to fail. Why is this now returning null in the latest version of
Seesmic Desktop when, in previous versions, it did not? Do I need to
change my plugin to access this information in a different way? If so,
how? I've tried a couple dozen ways with no success.

Thanks!

Biggert

unread,
Dec 15, 2011, 10:58:49 AM12/15/11
to Seesmic Desktop Platform Development
No replies yet... I guess I wasn't detailed enough. I have a plugin
for Seesmic Desktop. It is using the latest SDP SDK. After the most
recent released Seesmic Desktop update, Seesmic would no longer open.
I looked in the log file and it appeared to be due to a Object
referenced error happening when my plugin is loaded via MEF. After
digging through my plugin code and literally watching its
initialization, it calls the following in my Plugin's Initialize
method:

StorageService.GetValue<bool>(...)

It doesn't even get that far to the "GetValue" method because, per the
code below, the StorageService returns null.... but all I'm doing is
getting the MEF'd imported StorageService. The code below came from
this message board as a way to save settings for a plugin.

Again, I changed nothing in my plugin.... the recent Seesmic Desktop
update broke it and now I'm trying to fix it.

George Ionita

unread,
Dec 16, 2011, 3:51:31 AM12/16/11
to seesmic-d...@googlegroups.com
Hi,
 
Apologies for the late response. I've been checking our code and it seems that for our plugins the storage service is properly imported. Before we go forward with fixing this, let's make sure that you are using the sdk that is associated with our latest build (1.2.0.1897). Please download it from here, rebuild your project against it and let us know if you can still reproduce the issue:
 
 
Thanks,
George

Biggert

unread,
Dec 18, 2011, 5:18:35 PM12/18/11
to Seesmic Desktop Platform Development
Sam problem. The fun part is I got it working but removing the
"settings" that my plugin allows/stores. In this case, it was failing
due to the StorageService was always returning null when the plugin
was loaded after being imported (MEF) so I removed the call that ran
to get the stored setting and now the plugin works fine for obvious
reasons. The settings aren't all that important to my plugin so I
guess I'll just remove them.

Biggert

unread,
Dec 18, 2011, 10:29:44 PM12/18/11
to Seesmic Desktop Platform Development
I think I figured it out on my own. Again, still baffling to why it
was an application change (version) that exposed it and I made no
changes to my plugin. It appears a race condition was occurring in
regards to accessing the StorageService. The previous code I mentioned
was actually okay... the loading of this in the Plugin's (IPlugin)
Initialize method ended up running fine. But in my Plugin's
TimelineItemProcessor ( ITimelineItemProcessor), I make a call to my
settings class which attempts to use the StorageService too... and it
is here that the Object referenced error gets thrown because the
StorageService returned is NULL. How it gets to this point before my
Plugin is fully loaded by IPlugin via MEF I have no idea but it
does... I took out the call the initialization of my Settings class
that gets the value from the StorageService and it seems to work fine
now. Go figure....

George Ionita

unread,
Dec 19, 2011, 3:58:36 AM12/19/11
to seesmic-d...@googlegroups.com
Thank you for the report.
 
Yes, composition and other aggregations are only guaranteed when Initialize is called on your plugin.
George

Biggert

unread,
Dec 19, 2011, 4:37:26 PM12/19/11
to Seesmic Desktop Platform Development
That's the problem... I am calling Initialize on my plugin and it runs
correctly just like it always has. The thing is, from what appears to
be happening given the debug of my code, in the latest version of
Seesmic, the TimelineItemProcessor is already off and running before
the Initialize method is completed. So it's a race condition... and
it's one that either never happened or my plugin just always got lucky
every time it was run in the older versions of Seesmic Desktop but now
it happens every time in the new version of Seesmic Desktop.

I'm adjusting my code but it's pretty crappy that I now have to
manually update my plugin XAP file to get Seesmic Desktop working or
else it fails completely.... which means I can't even give users the
opportunity to update the plugin via the Seesmic Desktop UI.... either
they copy in the new XAP file manually or Seesmic Desktop doesn't work
at all.

George Ionita

unread,
Dec 20, 2011, 2:57:56 AM12/20/11
to seesmic-d...@googlegroups.com
What do you mean by TimelineItemProcessor is already off and running?
Reply all
Reply to author
Forward
0 new messages