读书人

怎么将c#反射改成VB.NET

发布时间: 2012-03-14 12:01:12 作者: rapoo

如何将c#反射改成VB.NET
/// <summary>
/// 创建tbUser数据层接口。1
/// </summary>
public static Tianli.IDAL.ItbUser CreatetbUser()
{

string ClassNamespace = AssemblyPath +".tbUser";
object objType=CreateObject(AssemblyPath,ClassNamespace);
return (Tianli.IDAL.ItbUser)objType;
}

//使用缓存
private static object CreateObject(string AssemblyPath,string classNamespace)
{
object objType = DataCache.GetCache(classNamespace);
if (objType == null)
{
try
{
objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);
DataCache.SetCache(classNamespace, objType);// 写入缓存
}
catch//(System.Exception ex)
{
//string str=ex.Message;// 记录错误日志
}
}
return objType;
}

[解决办法]
http://www.developerfusion.com/tools/convert/csharp-to-vb/
[解决办法]
http://www.developerfusion.com/tools/convert/csharp-to-vb/
这个网页转换.

结果如下:

VB.NET code
Public Shared Function CreatetbUser() As Tianli.IDAL.ItbUser    Dim ClassNamespace As String = AssemblyPath & ".tbUser"    Dim objType As Object = CreateObject(AssemblyPath, ClassNamespace)    Return DirectCast(objType, Tianli.IDAL.ItbUser)End Function'使用缓存Private Shared Function CreateObject(AssemblyPath As String, classNamespace As String) As Object    Dim objType As Object = DataCache.GetCache(classNamespace)    If objType Is Nothing Then        Try            objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace)                ' 写入缓存            DataCache.SetCache(classNamespace, objType)        Catch                'string str=ex.Message;// 记录错误日志            '(System.Exception ex)        End Try    End If    Return objTypeEnd Function 

读书人网 >VB Dotnet

热点推荐