How can I convert my C# code to DLL file in a way that the user of DLL can’t view my source code?
如何以DLL的用户无法查看源代码的方式将我的C#代码转换为DLL文件?
When I make DLL in the way I always do by making a class library project, importing my classes and compiling it, the source code can still be viewed.
当我通过创建类库项目,导入我的类并编译它来创建DLL时,仍然可以查看源代码。
8 个解决方案
#1
I believe you are looking for an obfuscator. This is a tool that will take a compiled DLL and rewrite the code with the intent of it not being meaningfully decompiled by another user. Visual Studio comes with a free Dotfuscator
我相信你正在寻找一个混淆器。这是一个工具,它将采用编译的DLL并重写代码,意图是它没有被另一个用户有意义地反编译。 Visual Studio附带一个免费的Dotfuscator
Note, this will not actually prevent people from looking at your code. They will instead be looking at a very weird translation of your code. There is no way to prevent people from looking at decompiled versions of your code in C# or any other .Net language for that matter.
请注意,这实际上不会阻止人们查看您的代码。相反,他们会查看代码的非常奇怪的翻译。没有办法阻止人们在C#或任何其他.Net语言中查看代码的反编译版本。
This is not something that is unique to C#. It is fact a flaw of every language in existence. It's perfectly possible to decompile C code. The difference though is it's much easier to maintain a lot of the original code structure when decompiling managed languages (.Net and Java for instance) because the metadata maintains the original structure.
这不是C#独有的东西。事实上,这是现存每种语言的缺陷。完全可以反编译C代码。不同之处在于,在反编译托管语言(例如.Net和Java)时,维护大量原始代码结构要容易得多,因为元数据维护了原始结构。
#2
obfuscation is what you want to search for.
混淆是你想要搜索的。
There is a free one (that is limited) in visual studio called Dotfuscator.
视觉工作室中有一个名为Dotfuscator的免费(有限)。
Uses fancy methods to rename your code and alter flowpaths to obscure it.
使用花哨的方法重命名代码并更改流路径以模糊它。
#4
If you are developing desktop applications converting your code to Dll will not hide the it( there are many tools to decompile the dll or exe files).
如果您正在开发将代码转换为Dll的桌面应用程序,则不会隐藏它(有许多工具可以反编译dll或exe文件)。
but if you are using Asp.Net, then you can compile your site to Dll, and the code will not be visible in the aspx pages, it will be compiled to Dll, you can do that by right click on your project on solution explorer, then choose Publish website
但是如果您使用的是Asp.Net,那么您可以将您的站点编译为Dll,并且代码将不会在aspx页面中显示,它将被编译为Dll,您可以通过右键单击解决方案资源管理器上的项目来实现,然后选择发布网站
But in all cases .Net Exe files and DLL will be easy to decompile and extract the source code again, unless you use tool to obfuscator your code.
但在所有情况下.Net Exe文件和DLL都很容易反编译并再次提取源代码,除非您使用工具来混淆代码。
#5
are you talking about ASP.NET ? Websites ? hide the aspx and cs source codes?
你在谈论ASP.NET吗?网站?隐藏aspx和cs源代码?
if yes, please see my question :
如果是的话,请看我的问题:
pre compile website in Setup & Deployment
在安装和部署中预编译网站
:)
#6
If you mean, the end-user can view your source code by decompiling it, you can protect yourself using an obfuscator.
如果您的意思是,最终用户可以通过反编译来查看您的源代码,您可以使用混淆器来保护自己。
There is standard obfuscator build in into Visual Studio. In the menu choose Tools / Dotfuscator community edition.
Visual Studio中内置了标准的混淆器。在菜单中选择Tools / Dotfuscator社区版。
#7
I think my reply to a similar question about JavaScript obfuscation applies here as well: in short, why bother? Your question has already been answered here ("use an obfuscator"), but I thought it wouldn't hurt to find out what your motivations are. Generally, code that you give to people is "in the hands of the enemy" -- if somebody wants to use it/figure out how it works badly enough, they will.
我认为我对JavaScript混淆的类似问题的回答也适用于此:简而言之,为什么要这么麻烦?你的问题已在这里得到解答(“使用混淆器”),但我认为找出你的动机并不会有什么坏处。一般来说,你给人的代码是“掌握在敌人手中” - 如果有人想要使用它/弄清楚它是如何工作的,那么它们就会。
#8
This link might be helpful to you.. http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
此链接可能对您有所帮助.. http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
#1
I believe you are looking for an obfuscator. This is a tool that will take a compiled DLL and rewrite the code with the intent of it not being meaningfully decompiled by another user. Visual Studio comes with a free Dotfuscator
我相信你正在寻找一个混淆器。这是一个工具,它将采用编译的DLL并重写代码,意图是它没有被另一个用户有意义地反编译。 Visual Studio附带一个免费的Dotfuscator
Note, this will not actually prevent people from looking at your code. They will instead be looking at a very weird translation of your code. There is no way to prevent people from looking at decompiled versions of your code in C# or any other .Net language for that matter.
请注意,这实际上不会阻止人们查看您的代码。相反,他们会查看代码的非常奇怪的翻译。没有办法阻止人们在C#或任何其他.Net语言中查看代码的反编译版本。
This is not something that is unique to C#. It is fact a flaw of every language in existence. It's perfectly possible to decompile C code. The difference though is it's much easier to maintain a lot of the original code structure when decompiling managed languages (.Net and Java for instance) because the metadata maintains the original structure.
这不是C#独有的东西。事实上,这是现存每种语言的缺陷。完全可以反编译C代码。不同之处在于,在反编译托管语言(例如.Net和Java)时,维护大量原始代码结构要容易得多,因为元数据维护了原始结构。
#2
obfuscation is what you want to search for.
混淆是你想要搜索的。
There is a free one (that is limited) in visual studio called Dotfuscator.
视觉工作室中有一个名为Dotfuscator的免费(有限)。
Uses fancy methods to rename your code and alter flowpaths to obscure it.
使用花哨的方法重命名代码并更改流路径以模糊它。
#3
Consider using an obfuscator.
考虑使用混淆器。
#4
If you are developing desktop applications converting your code to Dll will not hide the it( there are many tools to decompile the dll or exe files).
如果您正在开发将代码转换为Dll的桌面应用程序,则不会隐藏它(有许多工具可以反编译dll或exe文件)。
but if you are using Asp.Net, then you can compile your site to Dll, and the code will not be visible in the aspx pages, it will be compiled to Dll, you can do that by right click on your project on solution explorer, then choose Publish website
但是如果您使用的是Asp.Net,那么您可以将您的站点编译为Dll,并且代码将不会在aspx页面中显示,它将被编译为Dll,您可以通过右键单击解决方案资源管理器上的项目来实现,然后选择发布网站
But in all cases .Net Exe files and DLL will be easy to decompile and extract the source code again, unless you use tool to obfuscator your code.
但在所有情况下.Net Exe文件和DLL都很容易反编译并再次提取源代码,除非您使用工具来混淆代码。
#5
are you talking about ASP.NET ? Websites ? hide the aspx and cs source codes?
你在谈论ASP.NET吗?网站?隐藏aspx和cs源代码?
if yes, please see my question :
如果是的话,请看我的问题:
pre compile website in Setup & Deployment
在安装和部署中预编译网站
:)
#6
If you mean, the end-user can view your source code by decompiling it, you can protect yourself using an obfuscator.
如果您的意思是,最终用户可以通过反编译来查看您的源代码,您可以使用混淆器来保护自己。
There is standard obfuscator build in into Visual Studio. In the menu choose Tools / Dotfuscator community edition.
Visual Studio中内置了标准的混淆器。在菜单中选择Tools / Dotfuscator社区版。
#7
I think my reply to a similar question about JavaScript obfuscation applies here as well: in short, why bother? Your question has already been answered here ("use an obfuscator"), but I thought it wouldn't hurt to find out what your motivations are. Generally, code that you give to people is "in the hands of the enemy" -- if somebody wants to use it/figure out how it works badly enough, they will.
我认为我对JavaScript混淆的类似问题的回答也适用于此:简而言之,为什么要这么麻烦?你的问题已在这里得到解答(“使用混淆器”),但我认为找出你的动机并不会有什么坏处。一般来说,你给人的代码是“掌握在敌人手中” - 如果有人想要使用它/弄清楚它是如何工作的,那么它们就会。
#8
This link might be helpful to you.. http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
此链接可能对您有所帮助.. http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx