1

I saw this class which cannot be viewed by simple means:

enter image description here

how can I make my own helper class's method restricted like this?

Kokombads
  • 450
  • 2
  • 9
  • 23
  • 6
    What do you mean by "cannot be viewed by simple means"? Isn't the difference simply that your IDE does not have access to the sources of the assembly that contains that class, and thus relies on the information retrievable via reflection from the compiled assembly? If so, open the assembly in [ILSpy](http://ilspy.net/) and see for yourself how "restricted" the methods actually are :) – O. R. Mapper Sep 06 '17 at 08:33
  • i was asking if i created a helper class, how can i make that class like that, that other people are gonna need ilspy to view it – Kokombads Sep 06 '17 at 08:37
  • ... download a free c# decompiler (there are many available) and decompile it back to c#.... – Zohar Peled Sep 06 '17 at 08:37
  • 2
    @Kokombads Just build it in realese config. But each decompliler show the code. – BWA Sep 06 '17 at 08:38
  • @zohar, no, i was asking how can i make my own helper class be like that in the screen shot so that others who dont know about ilspy cannot see what's inside of my class – Kokombads Sep 06 '17 at 08:39
  • @Kokombads .net libs are always readable by decompilers, everybody can see source. You can use some obfuscators to decrese readiblity code. Or you can encrypt lib and in runtime decrypt it and load. – BWA Sep 06 '17 at 08:42
  • 2
    Compile your code. Open a new solution and add the dll you've just created as a reference. That's all you need to do. If you really want to hide your code, write it as a web service so the source never gets downloaded to the users computers. – Zohar Peled Sep 06 '17 at 08:43
  • 1
    What you may be looking for is covered in the question [How do I create and use a .NET metadata-only 'Reference Assembly'?](https://stackoverflow.com/q/7554984/15498) – Damien_The_Unbeliever Sep 06 '17 at 08:51

1 Answers1

1

The class you see is with System.dll, which is not the part of your solution but .Net library. If you really want to acheive the same what you can do is you can create class library seperatley, build it and add that dll to your solution instead of creating class library inside your solution. As project is not the part of solution people can't see code directly. But still they can disassemble to see it.

Vijayanath Viswanathan
  • 8,027
  • 3
  • 25
  • 43