I wonder if there is a way to restrict invoke call to a function? Let me make it clear.
[Assembly:a1]
Class A
{
function Af();
}
[Assembly:a2]
Class B
{
function Bf(){
//load Assembly a1
//InvokeMember to Af
}
}
After compilation I will have 2 assemblies. Now if I distribute to client, anyone can copy assembly 1 and invoke Af(). this function is returning setting.xml file after decrypting. 开发者_StackOverflow社区I want to stop access to my function from third party. Is there any way? any help is appreciated.
Thanks.
In .NET < 4.0, you could use the StrongNameIdentityPermission to restrict who's allowed to call your method. But even that will not stop someone who is determined to get hold of your secret data.
Nest class A in Class B.
You could obfuscate the method by requiring some argument be passed in for the method call to succeed. Base64Encode or MD5 of the current date could work (might fail near 00:00:00 even when called correctly though).
They could still reflect over your assembly and see how the method is called.
IMHO, your concern is unnecessary, but a good obfuscation tool would help (I haven't experimented with these much for .Net, but I've heard most are not good).
精彩评论