当前位置:编程学习 > C#/ASP.NET >>

【求助】关于强名称的问题

为了防止别人调用我的dll,所以用强名称来签名程序集。 

1)程序分为:SecureAssembly.dll和WinTestSecurit.exe  

2)用MyKey.snk 签名 SecureAssembly.dll和WinTestSecurit.exe  

3)测试代码如下: 

//SecureAssembly.dll 
namespace SecureAssembly 

    [StrongNameIdentityPermissionAttribute(SecurityAction.Demand, PublicKey = "0024...288C")] 
         public class SecuredClass 
        { 
            public SecuredClass() { } 
             
            public string GetTopSecretInformation() 
            { 
                return "Secret Code:000111"; 
                 
            } 
        } 


//WinTestSecurit 
namespace WinTestSecurit 

    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
        } 

        private void buttonX1_Click(object sender, EventArgs e) 
        { 
            string str; 
            SecureAssembly.SecuredClass new00 = new SecureAssembly.SecuredClass(); 
            str = new00.GetTopSecretInformation(); 
            MessageBox.Show(str); 

        } 
    } 



结果:WinTestSecurit。exe中无论用强名称签名与否都能够调用已经用强名称签名的SecureAssembly.dll 

希望大家帮帮我,看出错在哪里!  --------------------编程问答-------------------- 不懂,up --------------------编程问答-------------------- Framework 2.0+完全信任
StrongNameIdentityPermissionAttribute就直接失效了
补充:.NET技术 ,  .NET Framework
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,