Creating a COM interop using VS.NET 2005?

G

Guest

Hello,

I am trying to create and use a COM object with C#.NET 2005.

The assembly is set to "Register for COM interop" but when I am trying to
call it from VB on Word 2003 I am getting this error:

Run-time error '-2147024894 (80070002)':
File or assembly name COMTest3, or one of its dependencies, was not found.

The code for the COM:

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

namespace COMTest3
{
[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F")]
public interface ComNameITInterface
{
[DispId(1)]
string GetMyName();
}

[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ComNameITEvents
{
}

[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ComNameITEvents))]

public class NameIT : ComNameITInterface
{
public string GetMyName()
{
return "ABCDEF";
}
}
}


The code for the VB to call the COM:

Private Sub Document_New()
Dim x As New COMTest3.NameIT
MsgBox x.GetMyName()
Set x = Nothing
End Sub

Thanks for any help,
Asaf
 
K

Kevin Yu [MSFT]

Hi,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
P

Peter Huang [MSFT]

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.
 
P

Peter Huang [MSFT]

Hi

I am just checking to see how this is going.
Please drop me a quick note at your convenience to let me know the current
status of this issue.
If you have any concerns, please do not hesitate to let me know.
Thanks, and have a great day! :)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top