View previous topic :: View next topic |
Author |
Message |
i2s
Joined: 23 Mar 2011 Posts: 10 Location: Greece
|
Posted: Wed Mar 23, 2011 10:43 am Post subject: Error on locating reference assembly |
|
|
Hi,
I have a solution with several projects: a controls.dll, an objects.dll, a baseforms.dll, a dll with all functionality and three exe files that all use the same dlls.
This is because we have three similar products that use the same platform.
So we have decided to encrypt all three executables and our three base dlls and leaving the large dll that contains everything unencrypted to avoid the speed lose due to decryption.
When executing the bootstrap I got an error that one of the dlls could not be located. So here comes the first question:
Can an unencrypted dll referenced by bootstrap locate encrypted assemblies included as embedded resources within bootstrap?
I also tried encrypting all my output so everything is an embedded resource but that didn't work either. The program again could not locate one of the dlls.
At this point I have to say that internal dependencies of the dlls and executables to one another exist. So here comes my second question:
Can an encrypted assembly locate a resource within another encrypted assembly (both included as embedded resources in the bootstrap)?
That's all
Aris |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 23, 2011 11:48 pm Post subject: |
|
|
In our experience the decryption process adds very little overhead to the loading time. This is partly because in addition to encrypting .NET Encryptor compresses the assembly - this reduces the size of the assembly on disk reducing the time required to load it - which almost compensates for decompression/decryption time. So you could probably encrypt the larger dll without adversly affecting performance.
However if you don't want to encrypt one of the dlls you don't have to. An unencrypted dll can reference another DLL which is encrypted. The AssemblyLoader intercepts calls by the framework to load assemblies and if the assembly exists as an encrypted resource it will load it. I've just tried this with the sample project to ensure it does work. I created two library assemblies with reference dependencies like:
TestApp->UnencryptedAssembly->EncryptedAssembly
I then added a button to the main form which caused the Test App to load and use a class from the unencrypted assembly which in turn loads and uses a class from the encrypted assembly. This all works without any issues.
Some things to check however are:
1. Each assembly you encrypt must be added to the Bootstrap project under the Assemblies directory and the Build Action set to "Embedded Resource". If you forget to set the Build Action you will get assembly load errors.
2. The unencrypted assembly must be copied into the bin directory that you are executing the Bootstrap in. You can either do this manually or by adding a postbuild event.
Quote: | Can an encrypted assembly locate a resource within another encrypted assembly (both included as embedded resources in the bootstrap)? |
It depends what you mean by "locate a resource". Encrypted assemblies can certainly reference and call other encrypted assemblies. If however you have code that attempts to access the underlying file that an assembly is loaded from then this may cause issues (because encrypted assemblies are loaded dynamically and there is no file).
The best approach would be to modify one the sample projects to put together a simplified example of how your assemblies actually reference and use each other. This may help clarify for you the issues involved. If you can't figure it out then you could email us the zipped modified sample and we can take a look at the issue for you. _________________ Infralution Support |
|
Back to top |
|
|
i2s
Joined: 23 Mar 2011 Posts: 10 Location: Greece
|
Posted: Wed Mar 30, 2011 9:37 am Post subject: |
|
|
Here is the solution to my problem:
The enc assemblies in the Assembly folder on the selution explorer tree in VS are CASE SENSITIVE!!!
So if you include and calling you get an error.
I renamed my assembly and I was ok.
thanks for clearing things out.
PS. Indeed using an encrypted assembly is not realy slower. Its ok. however I got 6mb larger installation |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 30, 2011 9:40 pm Post subject: |
|
|
Normally if you have just one executable the resulting installation package ends up about the same size (or a little smaller). I'm guessing yours is larger because you have 3 exes that use common DLLs and these are now encrypted into each of the exes rather than being shared. Is that right? _________________ Infralution Support |
|
Back to top |
|
|
i2s
Joined: 23 Mar 2011 Posts: 10 Location: Greece
|
Posted: Thu Mar 31, 2011 12:13 pm Post subject: |
|
|
what I do is I encrypt each exe and dll separatelly. I am not shure If this causes everyhting to to add together three times due to the dependency.
Also the three exe scheme is going to go and instead use a single exe with arguments.
I will investigate and Let you know. |
|
Back to top |
|
|
|