Red Gate forums :: View topic - Assembly embedding with MEF ?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

Assembly embedding with MEF ?

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
clement_911



Joined: 22 Dec 2010
Posts: 7
Location: AU

PostPosted: Wed Dec 22, 2010 10:29 am    Post subject: Assembly embedding with MEF ? Reply with quote

Hi

I have tried the assembly embedding functionality in my Silverlight Application but it does not seem to play well with MEF.

When the code reaches "CompositionInitializer.SatisfyImports(this);", the import is failing and throws an exception.

My guess is that MEF cannot find the type because it belong into an embedded assembly, which has not been used so far.

From what I've read, the embedding feature will load the embedded assembly when it is first used. Then I guess a work around would be to force all embedded assemblies to be loaded as soon as the application starts.
Is it possible to achieve ???????

Cheers
Back to top
View user's profile Send private message
ShortAngry



Joined: 02 Dec 2010
Posts: 14

PostPosted: Thu Dec 23, 2010 11:09 am    Post subject: Reply with quote

As I said in your other post, getting sa to work with silverlight can be a bit problematic. You'll have to exclude bits of your code to get it to work. Alex Davies also has some helpful suggestions here: http://www.red-gate.com/MessageBoard/viewtopic.php?t=12271

As ever, If in doubt get in touch with support@red-gate.com
Back to top
View user's profile Send private message
clement_911



Joined: 22 Dec 2010
Posts: 7
Location: AU

PostPosted: Thu Dec 23, 2010 11:58 am    Post subject: Reply with quote

The link you provided is about a different problem.

It would be good if it was possible to have embedded assemblies be loaded as normal dependencies rather than specially treated.
MEF and other API would then work out of the box with them.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6670

PostPosted: Thu Dec 23, 2010 2:49 pm    Post subject: Reply with quote

Hi,

Embedded assemblies should bind in exactly the same way as before they were embedded. I think the issue you have is with obfuscation changing the names of methods and properties. Try it without obfuscation and see if it works.

Microsoft seems to be breaking its' own rules are invoking private methods in DLLs and that is wreaking havoc with smartassembly-obfuscated methods because we assume private methods are not going to be called using Reflection. At least this is the case with Silverlight so probably with MEF as well.

Bottom line is if you are using any technology that leverages reflection, you have to do a heckuva lot of testing after you obfuscate it and you have to know the technologies you're working with at a pretty in-depth level.
Back to top
View user's profile Send private message
clement_911



Joined: 22 Dec 2010
Posts: 7
Location: AU

PostPosted: Thu Dec 23, 2010 9:14 pm    Post subject: Reply with quote

I see.
As far as I know, MEF is just a library and is limited to the same silverlight rules as everyone (it's even open sourced).
I think it relies on loading all the assemblies in the manifest file. However, apparently a new manifest file is created when embedding assemblies, so that might be why MEF is not able to find the types on the dependencies.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6670

PostPosted: Fri Dec 24, 2010 10:24 am    Post subject: Reply with quote

I'm vaguely aware that you can have problems when you have DLL assemblies that contain nothing but type declarations. Is that how you're working as well?
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group