将VB.NET转换为C# - VS2008,VB.NET使用Interaction.CreateObject() [英] Converting VB.NET to C# - VS2008, VB.NET uses Interaction.CreateObject()

查看:211
本文介绍了将VB.NET转换为C# - VS2008,VB.NET使用Interaction.CreateObject()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在C#中找到一种方法来做什么Interaction.CreateObject(字符串ProgId,字符串ServerName)在VB.NET中做什么。



那么还有另外一种方法吗?是用于创建我们在VB.NET中使用的供应商DLL与C#之间的互操作性?



主要问题是此功能仅在MS.VB.dll中可用和VB.MET是非常宽容的。它允许我们只编写ProgID参数而不是ServerName,从而自动创建重载实现。另一方面,C#需要提供所有参数,我不知道它在ServerName中寻找什么,因为应用程序仅在本地运行。



是否有清洁工在C#中创建这种互操作性的方法,如果是这样的话,你能告诉我一个可行的代码示例吗?



在ObjectBrowser中查看DLL时,它显示了Vendor.DLL作为Interop.Vendor,这是否意味着我可以像在VB6中那样引用它?



谢谢。

I need to find a way in C# to do what Interaction.CreateObject(string ProgId, string ServerName) does in VB.NET.

So is there another was to create the interoperability between the vendor DLL that we use in VB.NET with C#?

Primary problem is that this function is only available in MS.VB.dll and VB.MET is very forgiving. It allows us to only program the ProgID parameter and not the ServerName and thereby automatically creating an overloaded implementation. On the other had C# requires all parameters to be provided, I have no idea what it is looking for in ServerName because the application runs locally only.

Is there a cleaner way to create this interoperability work in C#, if so could you show me an example of the code that will work?

In looking at the DLL in ObjectBrowser it shows the Vendor.DLL as Interop.Vendor, does this mean I can just reference it like we did back in VB6?

thanks.

推荐答案

尝试检查 MSDN文档创建对象。如果单击语法部分的C#选项卡,您将看到它是如何工作的。



[加法]

除了有关CreateObject的文档,您询问将出现在输出文件夹中的interop.vendor.dll。这是COM组件的自动生成包装器,您可以通过添加对项目中组件的引用来获得。
Try checking the MSDN Documentation on CreateObject. If you click on the C# tab in the Syntax section, you will see how it works.

[Addition]
In addition to the documentation on CreateObject, you ask about the interop.vendor.dll that will appear in your output folder. This is an autogenerated wrapper for the COM component that you get by adding a reference to the component in your project.


这篇关于将VB.NET转换为C# - VS2008,VB.NET使用Interaction.CreateObject()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆