Protecting class

P

Peter Schmitz

Hi everyone,

I currently need to write a solution that consists of three parts: the main
application, a utility class library (*.dll) and a third application
(which
is written by some third-party developers).
Now, the utility DLL contains some functions I want to be accessible for
anyone who likes to reference this library in his/her own projects.
However,
there are some functions that shall only be accessible for my main
application (and not for the third-party application). Is there any way to
achieve such a thing?

Best wishes,

Peter
 
M

Michel Posseth [MCP]

Peter Schmitz said:
Hi everyone,

I currently need to write a solution that consists of three parts: the
main
application, a utility class library (*.dll) and a third application
(which
is written by some third-party developers).
Now, the utility DLL contains some functions I want to be accessible for
anyone who likes to reference this library in his/her own projects.
However,
there are some functions that shall only be accessible for my main
application (and not for the third-party application). Is there any way to
achieve such a thing?

Best wishes,

Peter

There are several ways to acomplish that

a few ideas

You can use a licensing scheme

Demand for your own methods a license key , ( could be in a second
constructor )
if the key is provided then execute the methods otherwise throw a license
exception
it would be nice if you mark the licensed methods as beeing so with a
documentation atribute so that third party developers see in intellicense
that it is a method that demands a license )


You can use CAS.

Sign all of your assemblies with the same strong-name, then Demand the
StrongNameIdentityPermissionAttribute attribute on your public, static
methods with your assembly signature's public key so they cannot be called
from other assemblies.


You can use GetEntryAssembly or GetCallingAssembly

http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.getcallingassembly.aspx
You can then detect if it is a valid product calling you or a third party
product and behave different


You can use the InternalsVisibleTo attribute


And i guess there are lots and lots more solutions to acomplish what you
want , however don`t forget that a .Net assembly can be decompiled so you
should also use a obfuscator and even that is not 100% guaranteed to keep
curious eyes out of your code .


HTH

Michel Posseth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top