首页 > 解决方案 > 在 C# 中将经典的 asp 代码转换为 asp.net 代码

问题描述

嗨,我目前正在从事 asp.net webform 项目,我想使用从经典 asp 中解密密码的 dll 并在我的新项目中使用,我只有 dll。我无法将它所说的 dll 添加到引用中A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component.

Dll name: SamUtils.dll

这是经典asp上的代码

set Cipher = server.createobject("SamUtils.Cipher")
        Cipher.KeyString = Session("UserName")
        Cipher.MainText = RSPassword("Password")
        Cipher.Decrypt
        OldPassword = Cipher.MainText
        set cipher = nothing 

这就是我开始的,但我不知道如何继续或我在正确的道路上

[DllImport(@"C:\Users\nx011116\Documents\projects\WebApps\WebApps\bin\SamUtils.dll", CharSet = CharSet.Unicode)]
        public static extern void Cipher();

更新代码

using System.Runtime.InteropServices;

// Use DllImport to import the Cipher function.
[DllImport("SamUtils.dll")]
public static extern string SamUtilsCipher(string username, string password)
{
     //-- i dont know whats next
}

对不起,我是新手,希望有人帮我解决这个问题

标签: c#asp.net.net

解决方案


推荐阅读