我在.NET中创建了一个C# Com Interop类,并且已经在我的开发机器上适当地注册了它,同时在程序集中将Com-Visible设置为true。但是,当我在VB6应用程序中引用库时,我能够看到库名称、类名称,但没有与它们相关联的任何方法或属性?
如果有人能帮我解决这个问题,我已经卡了很长时间了!
这是我的类:
如果有人能帮我解决这个问题,我已经卡了很长时间了!
这是我的类:
using System;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace VNDBUtils
{
public enum VNConstants : long
{
cenMySQLDataStore = 32
}
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("CF4EFB82-6EE1-4A84-9CA9-07B135888B68")]
[ComVisible(true)]
public interface IVNSqlFormatter
{
//Properties
long DS_Type { get; set; }
string DS_Query { get; set; }
//Methods
string Format_Entity(string strString);
string MqStrMan_MakeStringEndWith(string strString, string strMatch);
bool MqStrMan_StringEndsWith(string strString, string strMatch);
string MqStrMan_MakeStringStartWith(string strString, string StrMatch);
bool MqStrMan_StringStartsWith(string strString, string strMatch);
string Right(string value, int length);
string Left(string value, int maxLength);
string Format_Value(string strString);
}
[ClassInterface(ClassInterfaceType.None)]
[Guid("3884D59D-AB76-41E7-82B6-21C66DBDCBF3")]
[ComVisible(true)]
public class VNSqlFormatter : IVNSqlFormatter
{
private const string SQUARE_LEFT = "[";
private const string SQUARE_RIGHT = "]";
public long DS_Type { get; set; }
public string DS_Query { get; set; }
public string Format_Entity(string strString)
{
strString = strString.Trim();
if (DS_Type == (long)VNConstants.cenMySQLDataStore)
{
return strString;
}
else
{
return MqStrMan_MakeStringEndWith(MqStrMan_MakeStringStartWith(strString, SQUARE_LEFT), SQUARE_RIGHT);
}
}
public string MqStrMan_MakeStringEndWith(string strString, string strMatch)
{
if (MqStrMan_StringEndsWith(strString, strMatch) == false)
{
return strString + strMatch;
}
else
{
return strString;
}
}
public bool MqStrMan_StringEndsWith(string strString, string strMatch)
{
return String.Equals(Right(strString, strMatch.Length), strMatch);
}
public string MqStrMan_MakeStringStartWith(string strString, string strMatch)
{
if (MqStrMan_StringStartsWith(strString, strMatch) == false)
{
return strMatch + strString;
}
else
{
return strString;
}
}
public bool MqStrMan_StringStartsWith(string strString, string strMatch)
{
return String.Equals(Left(strString, strMatch.Length), strMatch);
}
public string Right(string value, int length)
{
if (String.IsNullOrEmpty(value))
{
return String.Empty;
}
return value.Length <= length ? value : value.Substring(value.Length - length);
}
public string Left(string value, int maxLength)
{
if(String.IsNullOrEmpty(value))
{
return String.Empty;
}
maxLength = Math.Abs(maxLength);
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
}
public string Format_Value(string strString)
{
return strString.Replace("'", "''");
}
}
}
ProgId
属性,即ProgId("VNDBUtils.VNSqlFormatter")
。这可能是问题,也可能不是,我知道我所有的COM互操作类都有一个。 - Der Kommissar.tlib
文件是否已生成? - Der Kommissar