如何在.net框架中创建自己的扩展..是否可能 [英] how to create a own extention in .net framework .. is it possaible

查看:76
本文介绍了如何在.net框架中创建自己的扩展..是否可能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在.net框架(如.dll,.exe,docx..etc等)中创建自己的扩展名.
plz help ...

how to create a own extention in .net framework like .dll ,.exe,docx..etc .. make our own extensions ....is it possiable ???
plz help ...

推荐答案

如果您是指扩展方法,则可以:
If you mean extension methods, then yes:
        string s = "Hello";
        string t = s.DoSomething();
        ...

public static class ExtensionMethods
    {
    public static string DoSomething(this string s)
        {
        return "*" + s + "*";
        }
    }


您的意思是编写基于.NET的其他框架,并添加与.NET本身相同的应用程序可以使用的某些功能吗?

您当然可以做到.除了具有良好的架构和编程技巧(当然)之外,您还需要入门,这是对Global Assembly Cache(GAC)的充分理解:
http://en.wikipedia.org/wiki/Global_Assembly_Cache [ http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ex0ss12c.aspx [ ^ ].

此CodeProject文章也可能会有所帮助:
对.NET全局程序集缓存进行神秘化 [ http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx [ ^ ].

强命名事物的概念基于强密钥公钥密码学的概念.粗略地讲,它几乎可以确保对程序集进行全球唯一的标识,并可以对程序集的真实性进行强加密验证.请钻入:
http://en.wikipedia.org/wiki/Strong_name [ http://en.wikipedia.org/wiki/Public-key_cryptography [强名称解释 [
Do you mean writing some other framework based on .NET and adding some functionality which could be used by the applications the same was as .NET itself?

You certainly can do it. All you need to get started, in addition to good architectural and programming skills (of course), is good understanding of the Global Assembly Cache (GAC):
http://en.wikipedia.org/wiki/Global_Assembly_Cache[^].

Please see also:
http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx[^],
http://msdn.microsoft.com/en-us/library/ex0ss12c.aspx[^].

This CodeProject article can also be helpful:
Demystifying the .NET Global Assembly Cache[^].

One of the major prerequisite to this is understanding of the strong-named assemblies:
http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx[^].

The notion of strong-named thing is based on the notion of strong key and and public-key cryptography. Roughly speaking, it can nearly ensure a world-unique identification of your assembly, and cryptographically strong validation of the authenticity of an assembly. Please drill in:
http://en.wikipedia.org/wiki/Strong_name[^],
http://en.wikipedia.org/wiki/Public-key_cryptography[^].



Again, there is a CodeProject article which could be helpful here:
Strong Names Explained[^].

[END EDIT]

In a nutshell, you develop some .NET-based framework, generating some keys and giving strong names to all of the assemblies. Seriously develop compatibility and versioning technique for your framework (if you ever want to upgrade it). Then, develop some installation or deployment procedure (MSI, EXE,.. anything) to install this framework onto GAC. When you do it, all your framework will became universally accessible to the applications using it — the problem is solved.

—SA


这篇关于如何在.net框架中创建自己的扩展..是否可能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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