A Simple C# DLL - how do I call it from Excel, Access, VBA, VB6? -


I have written a simple class library in C #

 using the  system. Namespace Testdale {public class test {public string hellowald {return {return "hello world"; }}}}  

My question is how can I call this HelloWorld function from Microsoft Office Visual Basic (which I think is VB6)?

My first step was to add DLL as a reference - but browsing and compiling DLL message selection can not be added "reference to specified file." Was thrown.

Why does anyone / how to get this working?

Thanks in advance so much!

You can use a static member via COM interop can not do. Actually your code does not compile too, the method must be in a class. Here's how you can:

  [InterfaceType (ComInterfaceType.InterfaceIsDual)] [Guid ("01A31113-9353-44cc-A1F4-C6F1210E4B30")] // Your own GUID public interface Allocation of _Test {string HelloWorld {get; } [Class interface (class interface type .none)] [Good ("E2F07CD4-CE73-4102-B35D-119362624C47") // Your own GUID [program ("TestDale Test")] Public Class Test: _Test { Public string hello {get {return "hello, world!"; }}}  

Choose Project Properties Build tab, register for COM interop. You can quickly see the results

  Moderate o: set o = Create object ("test del test") MSBBX O. holdworld  

You can also refer to and use the initial binding:

  Test Del Test Set oo = New Test Dell. Text Messbox .HoldWorld  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -