Options

Not referenced assemblies loaded with reflection

lechuckcaptainlechuckcaptain Posts: 4
edited December 18, 2012 10:55AM in SmartAssembly
Hi,

I have a big VS2008 solution with many projects and many compiled assemblies, and I want to obfuscate them, and if possible embed them in only one executable.

The main problem is that some assemblies aren't referenced by the main executable, because they are loaded at runtime through reflection. So, SmartAssembly doesn't load these assemblies, and I can't add them to the final executable.

Is there a way I can avoid this problem?

Thank you in advance,

Marco

Comments

  • Options
    SmartAssembly will only merge or embed assemblies which are in the references metadata. So you will need to add the reference to the main assembly for SmartAssembly to detect it.
    Thanks,
    James Davies
    Technical Support Engineer
    Red Gate Software
  • Options
    Thank you for the answer,

    I tried adding the references to the assemblies without loading them, but it seems that {SA} doesn't load the assemblies.that aren't directly loaded. Can you confirm that?

    Do I have to explicity load all the assemblies that I want to obfuscate in order to let {SA} to detect them?

    Marco
  • Options
    Any suggestions?
  • Options
    What James said. You need to create a reference and possibly even use one of the referenced assemblies in your code (by creating a class from it). I say that because I noticed .NET doesn't load an assembly merely because there is a reference and you actually have to do something with the reference and I'd imagine SA behaves the same way.
  • Options
    So you'are not compatible with MEF ...
    Morevover, we cannot use your solution with a XAML styles assembly ...

    You should permit us to add assemblies that SA does't find ! :x
  • Options
    I had this problem too. My workaround is to add some code that directly references the .dll, even though the method that does so is never called in my code.
    [DoNotPrune]
    public static class SmartAssemblyFix
    {
      public static Type ForceReferenceMethod() 
      {
        return typeof([Namespace.Of.Library].[SomeClassInLibrary]);
      }
    }
    
  • Options
    I can't, it is dynamically loaded when I add DLLs in my bin
Sign In or Register to comment.