从 c# 调用 vb6 dll

Calling vb6 dlls from c#(从 c# 调用 vb6 dll)
本文介绍了从 c# 调用 vb6 dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从 C sharp 应用程序调用 vb6 dll,而不使用注册表.我想在使用时使用 dll 的路径.我无法创建 vb dll 类的对象.请帮忙!目前我写的代码如下:

I have been trying to call a vb6 dll from a C sharp application, without using the registry. I want to use the path of the dll while using it. I am unable to create an object of the class of the vb dll. Please help! The code I have written so far is as follows:

Assembly assem = Assembly.LoadFile("dll path");
Type classType = assem.GetType("classname");
MethodInfo method = classType.GetMethod("show"); //My methos is called show
method.Invoke(null,null); // I have to invoke the method using class object, which I am unable to create

推荐答案

VB6 DLL 是 COM DLL.通常您会注册 DLL(在注册表中),然后从您的 .NET 项目中添加对 VB6 DLL 的引用.

A VB6 DLL is a COM DLL. Usually you would register the DLL (in the registry) and then add a reference to the VB6 DLL from your .NET project.

这篇 MSDN 文章 提供了使用免注册 COM 的演练来自 .Net 应用程序.

This MSDN article gives a walkthrough of using registry-free COM from a .Net app.

这篇关于从 c# 调用 vb6 dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)