Skip to content

Instantly share code, notes, and snippets.

@Lazzlo2096
Created August 6, 2018 07:21
Show Gist options
  • Save Lazzlo2096/6c2cc85a620a4a7f6f5a0c00177b1e91 to your computer and use it in GitHub Desktop.
Save Lazzlo2096/6c2cc85a620a4a7f6f5a0c00177b1e91 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices; //Guid
namespace CSharp_COMObject
{
//using System.Runtime.InteropServices;
[Guid("E7C52644-7AF1-4B8B-832C-23816F4188D9")]
public interface CSharp_Interface
{
[DispId(1)]
string GetData();
}
[Guid("1C5B73C2-4652-432D-AEED-3034BDB285F7"),
ClassInterface(ClassInterfaceType.None)]
public class CSharp_Class : CSharp_Interface
{
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
//public static extern void OutputDebugString(string message);
public CSharp_Class()
{
//OutputDebugString("Created");
System.Console.WriteLine("Created");
}
public string GetData()
{
//OutputDebugString("Called");
System.Console.WriteLine("Called");
//if (System.Environment.Is64BitProcess)
// return "Hello from 64-bit C#";
// else
// return "Hello from 32-bit C#";
return "Hello from C#";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment