我用VC写了一个dll
用VB6.0可以正常调用
为什么用VB.net 和C# 都不可以?
是DLL的问题吗?

解决方案 »

  1.   

    没看到你咋调的不好说啊
    不过用vc.net调下看看 要是好用 用它封下,这样.net就好调用了
      

  2.   

    没弄过,如果是v7写的dll,肯定是可以在c#调用的
      

  3.   

    如果DLL有入口函数,就用regsvr32 ...../???.dll注册一下,然后做COM引用
    如果没有入口函数,用ImportDll,做外部函数引用吧
      

  4.   

    VB6.0代码:Private Declare Function ConvertMobile Lib "ConvertDll.dll" (ByRef MobileNo As String) As Long
    Public Function Decode(sMobile As String)
        Decode = ConvertMobile(sMobile)
    End Function
    VB.net代码:
    <DllImport("ConvertDll.dll")> _
    Private Shared Function ConvertMobile(ByRef MobileNo As String) As Integer
    Public Function Decode(sMobile As String)
        Decode = ConvertMobile(sMobile)
    End FunctionC# 代码: [DllImport("ConvertDll.dll")]  
    private static extern long   ConvertMobile(string MobileNo); private void Page_Load(object sender, System.EventArgs e)
    {
    string sPhoneNumber="13391558922";
    long  a=ConvertMobile(sPhoneNumber);
    }说明一下我用的是.net2003,DLL没有入口函数
      

  5.   

    如果是基于com开发的DLL,可以直接在.net平台下引用
    如果是win32的dll,就要用到P/Invoke方法调用。
    具体方法:上上楼