Red Gate forums :: View topic - Not referenced assemblies loaded with reflection
Return to www.red-gate.com RSS Feed Available

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

Not referenced assemblies loaded with reflection

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
lechuckcaptain



Joined: 01 Sep 2011
Posts: 3

PostPosted: Thu Sep 01, 2011 11:22 am    Post subject: Not referenced assemblies loaded with reflection Reply with quote

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
Back to top
View user's profile Send private message
james.davies



Joined: 19 Apr 2011
Posts: 46

PostPosted: Fri Sep 02, 2011 4:03 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
lechuckcaptain



Joined: 01 Sep 2011
Posts: 3

PostPosted: Fri Sep 02, 2011 4:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
lechuckcaptain



Joined: 01 Sep 2011
Posts: 3

PostPosted: Mon Sep 12, 2011 1:58 pm    Post subject: Reply with quote

Any suggestions?
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6582

PostPosted: Mon Sep 12, 2011 5:56 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Julien



Joined: 18 Dec 2012
Posts: 2

PostPosted: Tue Dec 18, 2012 3:30 pm    Post subject: Reply with quote

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 ! Mad
Back to top
View user's profile Send private message
eric-914



Joined: 30 Nov 2012
Posts: 28

PostPosted: Tue Dec 18, 2012 4:42 pm    Post subject: Reply with quote

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:
[DoNotPrune]
public static class SmartAssemblyFix
{
  public static Type ForceReferenceMethod()
  {
    return typeof([Namespace.Of.Library].[SomeClassInLibrary]);
  }
}
Back to top
View user's profile Send private message
Julien



Joined: 18 Dec 2012
Posts: 2

PostPosted: Tue Dec 18, 2012 4:55 pm    Post subject: Reply with quote

I can't, it is dynamically loaded when I add DLLs in my bin
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic 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