![]() |
Modifying Assembly Attributes (.NET)
Is there a way to modify Assembly Attributes of existing assembly?
What I want to achieve is to add InternalsVisibleTo attribute to expose assembly's internals to my library. |
You can use something like Mono.Cecil to rewrite parts of the file and then save the changed file. Check out Mono.Cecil here:
http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cecil/ dnlib is another similar library: https://github.com/0xd4d/dnlib You should be able to alter the attributes of classes and such to your needs to make it work as desired. |
I accomplished the task with Mono.Cecil, thanks.
By the way, I guess it's not possible to import .NET 4.0 module into .NET 2.0 assembly? |
You can if the 4.0 module exposes what you need via COM. The 2.0 assembly can then use the object(s) via COM. A straight import is not possible though because of the .NET version mis-match though.
You can see more info on how to accomplish this here: http://www.codeproject.com/Articles/204406/How-To-Use-a-NET-Based-DLL-From-NET-Based-Appl |
Thank you very much atom0s. Very useful.
Sorry to bother you, but I have one last problem. The app stores resources in separate .dll file. I had to remove Strong Name from the .exe, but then I noticed that it won't load strong-named .dll. Why? What am I missing here? |
These links may help some:
https://msdn.microsoft.com/en-us/library/s1sx4kfb(v=vs.100).aspx https://msdn.microsoft.com/en-us/library/xwb8f617(v=vs.110).aspx As MSDN states as well: Quote:
|
Sounds weird to me. An exe without strong name should be able to load a dll with strong name. Anyways, strong name doesn't work as far as I know. You could just modify things and maybe hook StrongNameSignatureVerification if the program checks the strong name.
An alternative solution is to simply re-sign everything using your own strong name :) |
I have read that paragraph, but as mr.exodia points out - the .exe has been stripped out of Strong Name, hence the question. Shouldn't it be able to load any strong-named .dll? Nonetheless, if I remove the Strong Name from resource .dll, it loads correctly then.
|
| All times are GMT +8. The time now is 10:02. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX