RE: Creating a COM interop using VS.NET 2005?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

By default ComVisible() = false,

Please try to code below.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace COMTest3
{
[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch),ComVisible(true)]
public interface ComNameITInterface
{
[DispId(1)]
string GetMyName();
}

[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),

InterfaceType(ComInterfaceType.InterfaceIsIDispatch),ComVisible(true)]
public interface ComNameITEvents
{
}

[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ComNameITEvents)),ComVisible(true)]
public class NameIT : ComNameITInterface
{
public string GetMyName()
{
return "ABCDEF";
}
}
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

.