老大,看不懂啊。能不能给个有说明的地方和。例子啊。 //bow 我用vb写了个com,得到自己想要的数据,然后把com用.net包装。调用 ,拿到数据了。问题是能不能用.net直接取。就是Dim phd1 As Object Dim sss As StringPublic Function hello(ByVal hello1 As String) As String Set phd1 = CreateObject("VisualPhd.Data") 这几句在.net里用什么代替。.net能不能直接象vb一样调用 visualphd.data。vb项目什么都没有引用。就可以直接得到数据。不知道用的哪个dll.查询注册表有个phdata.dll关联visualphd.data,但是添加到.net引用中失败。说不是合法的dll
using System.Reflection; public static object Create( string asmName, string typeName, object[] args ) { Assembly assemblyInstance = null; Type typeInstance = null; try { // use full assembly name to get assembly instance assemblyInstance = Assembly.Load( asmName ); } catch ( Exception e ) { throw new UIPException( Resource.ResourceManager.FormatMessage( "RES_ExceptionCantLoadAssembly", asmName ), e ); } // use type name to get type from assembly typeInstance = assemblyInstance.GetType( typeName , true, false); try { if( args != null ) { return Activator.CreateInstance( typeInstance, args); } else { return Activator.CreateInstance( typeInstance); } } catch( Exception e ) { throw new UIPException( Resource.ResourceManager.FormatMessage( "RES_ExceptionCantCreateInstanceUsingActivate", typeInstance ), e ); } }
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
ShowWindowAsync (instance.MainWindowHandle , WS_SHOWNORMAL);
我用vb写了个com,得到自己想要的数据,然后把com用.net包装。调用 ,拿到数据了。问题是能不能用.net直接取。就是Dim phd1 As Object
Dim sss As StringPublic Function hello(ByVal hello1 As String) As String
Set phd1 = CreateObject("VisualPhd.Data")
这几句在.net里用什么代替。.net能不能直接象vb一样调用 visualphd.data。vb项目什么都没有引用。就可以直接得到数据。不知道用的哪个dll.查询注册表有个phdata.dll关联visualphd.data,但是添加到.net引用中失败。说不是合法的dll
{
Assembly assemblyInstance = null;
Type typeInstance = null; try
{
// use full assembly name to get assembly instance
assemblyInstance = Assembly.Load( asmName );
}
catch ( Exception e )
{
throw new UIPException( Resource.ResourceManager.FormatMessage( "RES_ExceptionCantLoadAssembly", asmName ), e );
} // use type name to get type from assembly
typeInstance = assemblyInstance.GetType( typeName , true, false); try
{
if( args != null )
{
return Activator.CreateInstance( typeInstance, args);
}
else
{
return Activator.CreateInstance( typeInstance);
}
}
catch( Exception e )
{
throw new UIPException( Resource.ResourceManager.FormatMessage( "RES_ExceptionCantCreateInstanceUsingActivate", typeInstance ), e );
}
}