Assembly embedding with MEF ?

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, Alex.Davies, melvyn.harbour

Assembly embedding with MEF ?

Postby clement_911 » Wed Dec 22, 2010 10:29 am

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
clement_911
 
Posts: 7
Joined: Wed Dec 22, 2010 9:52 am
Location: AU

Postby ShortAngry » Thu Dec 23, 2010 11:09 am

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/vi ... hp?t=12271

As ever, If in doubt get in touch with support@red-gate.com
ShortAngry
 
Posts: 14
Joined: Thu Dec 02, 2010 12:29 pm

Postby clement_911 » Thu Dec 23, 2010 11:58 am

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.
clement_911
 
Posts: 7
Joined: Wed Dec 22, 2010 9:52 am
Location: AU

Postby Brian Donahue » Thu Dec 23, 2010 2:49 pm

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.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby clement_911 » Thu Dec 23, 2010 9:14 pm

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.
clement_911
 
Posts: 7
Joined: Wed Dec 22, 2010 9:52 am
Location: AU

Postby Brian Donahue » Fri Dec 24, 2010 10:24 am

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?
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am


Return to SmartAssembly 5

Who is online

Users browsing this forum: No registered users and 1 guest