日期:2014-05-18  浏览次数:20827 次

C#DLL的相关问题 大侠入
用C#生成了DLL文件,C#代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace LeonQtp
{
  public class Qtp_Msg
  {
  public static int MessageBoxL(string Msg, string Caption)
  {
  MessageBox.Show(Msg, Caption, MessageBoxButtons.OKCancel);
  return 0;
  }
  }
}

###############################################################################################
上述代码生成的DLL,可用C#调用成功
但是在QTP中,用下面语句调用失败:
Set CSharp_Msg = DotNetFactory.CreateInstance("LeonQtp.Qtp_Msg","C:\Leon\New\LeonQtp.dll")
 Ret = CSharp_Msg.MessageBoxL("Call by DotNetFactory!","by DNF obj")

Error如下:
Could not load file or assembly 'file:///C:\Leon\New\LeonQtp.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

大家帮忙看下吧~~~

------解决方案--------------------
降到2.0肯定可以,刚试过
------解决方案--------------------