Red Gate forums :: View topic - Accessing resources from merged assembly
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

Accessing resources from merged assembly

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



Joined: 06 Oct 2008
Posts: 15

PostPosted: Mon Feb 17, 2014 9:01 pm    Post subject: Accessing resources from merged assembly Reply with quote

I have a DLL with some icon files as resources that are accessed in a WPF XAML file. If I try to merge this DLL with my main executable in SmartAssembly (no other processing on it), I get a System.IO.FileNotFoundException indicating that my DLL can't be found, and thus my resource can't be loaded. If I embed the DLL instead of merge it, then my resource is loaded just fine. However, error reports for embedded assemblies don't show details like local and member variables, so I would prefer to merge the assembly instead.

Is there a way I can access a resource from an assembly that's been merged through SmartAssembly?

Thanks,

Brandon
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 224

PostPosted: Wed Feb 19, 2014 12:25 am    Post subject: Reply with quote

Hi Brandon,

Thanks for your post!

It sounds like the resource is probably being called on by name, but merging the DLL containing the icon files has destroyed the namespace so that this call no longer works.

Sorry to say, embedding the DLL would be the best way around this. To get local variables when embedding the DLL, it should work if you can first make a separate SmartAssembly project for it, apply error reporting, and then embed this protected DLL to your main exe.

(Just a note: to make sure SmartAssembly uses the protected version of the DLL, you can add a MandatoryPath attribute to your saproj file)

Hope this helps!
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
Back to top
View user's profile Send private message
dybalabj



Joined: 06 Oct 2008
Posts: 15

PostPosted: Thu Feb 20, 2014 6:42 pm    Post subject: Reply with quote

Thanks, that took care of my issue quite nicely!

Once other problem I noticed, though. The DLL is signed with a strong name key. I can re-sign it and them embed the result in my main application with no problem. However, if I check "I want to add tamper protection", then I get a SecurityException that the "Assembly has been tampered" when I run the final application. This only happens if the original DLL is not present in the folder containing my executable (for instance, in an installed version). If the DLL I'm embedding is still present in the folder, the SecurityException does not occur.

Note that I can enable the "References Dynamic Proxy" and "I want to use string encoding with improved protection" options with no problem (with or without the original DLL). SmartAssembly indicates that both of these options also add some sort of tamper protection as well.
Back to top
View user's profile Send private message
jessica.ramos



Joined: 23 Apr 2012
Posts: 224

PostPosted: Sat Feb 22, 2014 1:12 am    Post subject: Reply with quote

Hi Brandon,

I'm glad to hear that helped!

Regarding this new problem, there is unfortunately a known issue with embedding tamper protected assemblies as you are seeing.

Our tamper protection feature works by hooking into an assembly's static constructors and adding the 'StrongNameSignatureVerificationEx' windows API call to those methods (http://msdn.microsoft.com/en-us/library/ms232579(v=vs.100).aspx). This verification call uses GetExecutingAssembly to find the physical file of the tamper protected asssembly and then verifies that file's signature against the signature in its manifest.

The issue with embedding a tamper protected assembly though is that a physical file for it does not actually exist. Thus, the GetExecutingAssembly call fails and the signature verification ultimately fails as well. (but keeping a copy of the embedded DLL in the folder would prevent this)

I'm afraid that to embed the assembly, you will need to protect it without the "I want to add tamper protection" option enabled :/

Please let me know if you have any further questions on this!
_________________
Jessica Ramos
Technical Support
Red Gate Software Ltd.
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