Not referenced assemblies loaded with reflection

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, melvyn.harbour, dom.smith

Not referenced assemblies loaded with reflection

Postby lechuckcaptain » Thu Sep 01, 2011 11:22 am

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
lechuckcaptain
 
Posts: 3
Joined: Thu Sep 01, 2011 11:02 am

Postby james.davies » Fri Sep 02, 2011 4:03 pm

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
james.davies
 
Posts: 46
Joined: Tue Apr 19, 2011 2:39 pm

Postby lechuckcaptain » Fri Sep 02, 2011 4:26 pm

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
lechuckcaptain
 
Posts: 3
Joined: Thu Sep 01, 2011 11:02 am

Postby lechuckcaptain » Mon Sep 12, 2011 1:58 pm

Any suggestions?
lechuckcaptain
 
Posts: 3
Joined: Thu Sep 01, 2011 11:02 am

Postby Brian Donahue » Mon Sep 12, 2011 5:56 pm

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

Postby Julien » Tue Dec 18, 2012 3:30 pm

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
Julien
 
Posts: 2
Joined: Tue Dec 18, 2012 3:27 pm

Postby eric-914 » Tue Dec 18, 2012 4:42 pm

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.

Code: Select all
[DoNotPrune]
public static class SmartAssemblyFix
{
  public static Type ForceReferenceMethod()
  {
    return typeof([Namespace.Of.Library].[SomeClassInLibrary]);
  }
}
eric-914
 
Posts: 28
Joined: Fri Nov 30, 2012 5:51 pm

Postby Julien » Tue Dec 18, 2012 4:55 pm

I can't, it is dynamically loaded when I add DLLs in my bin
Julien
 
Posts: 2
Joined: Tue Dec 18, 2012 3:27 pm


Return to SmartAssembly 6

Who is online

Users browsing this forum: No registered users and 0 guests