在VB.net中创建DLL文件 [英] Creating DLL file in VB.net

查看:264
本文介绍了在VB.net中创建DLL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想创建一个DLL文件,其中包含我们软件的一些业务逻辑。

但我想要的是什么是其他人不应该使用该DLL。即,其他人不应该在他们的应用程序中引用DLL或者不能查看DLL中存在的函数。



我也创建了用于测试此DLL的DLL。以下是代码:

Hello,

I want to create a DLL file which will contain some business logic for our software.
But what i want is that other people should not be able to use that DLL. ie, other people should not be able to either reference the DLL in their application OR should not be able to view the functions present in the DLL.

I have also created a DLL for Testing this. Below is the code :

Public Class ABC
  Private Function ShowMessage(ByVal Str as String) as String
     Msgbox(Str)
  End Function
End Class



我编译了代码并创建了DLL文件。然后我创建了一个带有表单的Windows应用程序。

表格代码:


I compiled the code and created the DLL File. Then I Created a Windows Application With a Form.
Form Code :

Public Class Form1
   Declare Function ShowMessage Lib <dllname> Alias "ShowMessage" (ByVal Str as String) as String

   Private Sub Button1_Click()
      ShowMessage("Testing DLL")
   End Sub
End Class</dllname>



当我执行上面的代码时,它会在按钮Click上显示错误。

在DLL中找不到ShowMessage的入口点



C任何人请帮助我。

任何帮助将不胜感激。



提前致谢。等待回复很快。


When I execute the above code, it shows an error on button Click.
"Entrypoint for ShowMessage Not found in DLL"

Can anyone please help me in this.
Any help would be greatly appreciated.

Thanks in advance. Awaiting a reply soon.

推荐答案

有两种基本方法可以达到这个目的;



1)朋友大会;

http://msdn.microsoft.com/en-us/library/ 0tke9fxk.aspx [ ^ ]



2)除此之外,你可以使用混淆来阻止随意的代码小偷



除此之外,我不知道!
There are 2 basic methods to achieve this;

1) Friend Assemblies;
http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx[^]

2) on top of this, you can then use obfuscation to deter the casual code thief

other than this, i don't know!


添加对 System.Windows.Forms 的引用,它包含 MessageBox 您正在调用的方法。如果没有引用它就无法调用它。
Add a reference to System.Windows.Forms, it contains the MessageBox method that you're calling. It can't call it if it's not referenced.


Public Class Form1

dim showmsg as abc.abc



Private Sub Button1_Click()

showmsg.ShowMessage(测试DLL)

End Sub

end class




添加引用您创建的DLL,您在表单中尝试上面的代码。
Public Class Form1
dim showmsg as abc.abc

Private Sub Button1_Click()
showmsg.ShowMessage("Testing DLL")
End Sub
end class


add reference your DLL, that you created bedfore, and try above code in your form.


这篇关于在VB.net中创建DLL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆