-1

I have a Netframework DLL project in Visual Studio and the DLL is compiled in Release mode and used in another project, how I can restrict to load or the use about the DLL by another person than could stolen my DLL and use in his/her project?

Ejrr1085
  • 975
  • 2
  • 16
  • 29

1 Answers1

0

I found the solution with internal class and method:

Some class in My dll:

[assembly: InternalsVisibleTo("FriendAssembly")]
namespace MiLibrary
{

    internal class Class1
    {
        internal static string GetName()
        {
            return "My Name";
        }
    }
}

Another Project in some class:

namespace MyApp
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            txbText.Text = MiLibrary.Class1.GetName();
        }
    }
}

Only "FriendAssembly" has access to Class1. "Another Project" must have the assembly name as "FriendAssembly" (Menu Project -> Properties of "Another Project" -> Application -> Assembly Name)

InternalsVisibleToAttribute Class

Related questions in Stackoverflow:

Protect C# DLL from third party

How to protect dlls?

Ejrr1085
  • 975
  • 2
  • 16
  • 29