如何确保dll函数不被我的应用程序外使用? [英] how to secure dll functions from being used outside of my application?

查看:93
本文介绍了如何确保dll函数不被我的应用程序外使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制其他应用程序使用我编写的dll函数。

I want to restrict other application from using dll functions that I have written.

例如。
如果我有database.dll包含两个函数。

Eg. If i hav database.dll containg two functions.

public void InsertInToDatabse();
public void ClearDatabase();

现在,如果我的应用程序调用了InsertInToDatabse()并正在执行其他工作,那么直到此时其他应用程序通过引用database.dll来调用ClearDatabase(),数据库将变得更加清晰。那么我如何限制第三方应用程序对这些函数的调用?

Now If my application has called InsertInToDatabse() and is doing some other work,till this time if some other application calls ClearDatabase() by referencing database.dll , The databse would be cler out.So how can I restrict calls to these functions form third party application ?

推荐答案

如果您的dll是类库,则实际配置文件将是客户端应用程序之一(web.config或app .exe.config),并且只有授权的应用程序才能使用用户名,密码,数据库服务器和数据库名称正确的连接字符串。

if your dll is a class library the actual configuration file will be the one of the client application (web.config or app.exe.config) and in there only authorized applications will have proper connection string with username, password, db server and db name.

现在,即使未经授权的应用程序防止以您正在寻找的方式调用dll的方法,以防那些不良应用通过知道连接字符串而直接访问数据库,但它们仍然会混乱。

Now, even if unauthorized apps would be prevented to call you dll's methods in the way you are looking for, in case those bad apps have direct access to the database by knowing the connection string, they can still mess around.

这表示实际上,只要配置不在您的dll中,您就不必担心,因为只有授权的应用程序才能访问正确的数据库。

this would to say that in fact as long as the configuration is outside your dll you shouldn't worry because only authorized apps will be accessing the proper database.

这种方法仍然不能满足您的要求,那么您应该使用像CAS这样的安全检查,它可以让您指定可以调用某个方法的类或程序集,因此即使您的dll被另一个应用程序引用,它也不会起作用rk。请注意,在.NET 4(您在问题中为其添加了标签)中,整个安全层已更改,并且与旧版.NET Framework的工作方式不同,请查看本文以了解更多详细信息: http://msdn.microsoft.com/en-us/library/dd233103.aspx

if this approach still does not satisfy you, then you should be using security check like CAS which allows you to specify which class or assembly can be calling a certain method so even if your dll is referenced by another application it won't work. Beware that in .NET 4 (you tagged it in the question) the whole security layer has been changed and works differently from older .NET Framework versions, check this article for more details: http://msdn.microsoft.com/en-us/library/dd233103.aspx

这篇关于如何确保dll函数不被我的应用程序外使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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