Search code examples
c#dllcode-signing

Distribute secure DLL C#


I've written some code in C#, and I would like to distribute it as a DLL. I know there are a lot of resources for this, but I'm having a strange problem, and I'm new to C# and thus lack the vocabulary to properly search for solutions.

The situation is : I have my code in a Visual Studio project, and it works great. I can compile it, and I see the mycode.dll file in the bin. I believe that this (along with any other required DLLs) is what I need to pass on to other users. To check this, and to make sure things are working as I want them to, I created a second Visual Studio project to use the DLL I'd created.

For the most part everything looks good. The problem arises when I get a runtime error in the DLL code. When that happens, I get a dialog box describing the error, with "Break" and "Continue" options. If I choose "Continue" it takes me to the place in the source code where the error occurred. I don't want the user to be able to see my source code like this.

I've tried signing the project (in the Properties menu), but that doesn't seem to solve the problems, and also leads to compile time errors because some of the other DLLs I'm using aren't signed (at least, I think that's what the error means).

Is there a way to compile my code in to a DLL that will not allow the user to see any of the source code?

Thank you


Solution

  • Signing (Strong naming) a DLL have nothing to to with Obfuscation. When you deliver a dot.net assembly, everybody can decompile it. If you obfuscate it, it's harder to decompile, but not impossible.

    Signing is only a way to guaranty others projects using your DLL, that another DLL doesn't replace the original one.

    You can check yourself if you can decompile your assembly with reflector.

    PS : if a project using a signed DLL is not signed itself, it should not throw compile errors. It's the inverse which throw exceptions : when you use not signed assemblies in a signed project.