Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2007

Tip: Looking for answers? Try searching our database.

Problem with using created COM object with C#.NET 2005 under Excel    2003 (Framework 2.0)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rafał Giezgała - 23 Mar 2007 16:42 GMT
This is part of my assembly:

[assembly: ComVisible(true)]

[assembly: ClassInterfaceAttribute(ClassInterfaceType.None)]

// The following GUID is for the ID of the typelib if this project is
exposed to COM
[assembly: Guid("cd099def-f9fb-407f-b793-9db68f6b8a0b")]

This is my code:

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

namespace ExtraStuff
{
    [Guid("4E3BBC1B-625F-47bf-BE80-DAB84F1934BE"),
        InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
        ComVisible(true)]
    public interface IExtraStuff
    {
        [DispId(1)]
        double F2C(double val);
    }
   
    [Guid("F88DAD68-578A-4e23-BCFF-0FBBEC1C4B55"),
        ClassInterface(ClassInterfaceType.None),
        ComSourceInterfaces(typeof(IExtraStuff)),
        ComVisible(true)]
    public class ExtraStuffClass : IExtraStuff
    {
        public ExtraStuffClass()
        {                   
        }
       
        public double F2C(double val)
        {
            return ((5.0/9.0) * (val - 32.0));
        }
    }   
}

and excel vb code:

Option Explicit

Public Function F2C(val As Double) As Double
   Dim ccw As ExtraStuff.IExtraStuff
   Set ccw = New ExtraStuffClass
   F2C = ccw.F2C(val)
End Function

I put my dll to C:\Program Files\Microsoft Office\OFFICE11\ and I registered
that by:

regasm /tlb /codebase ExtraStuff.dll

And when I'm trying use it I get error:

'Run-time error '-2147024894 (80070002)'

In oleview.exe raport everything seems to be OK. Can anyone solve my problem
?
bobahop@gmail.com - 23 Mar 2007 17:46 GMT
In C# I would have to name the interface _IExtraStuff, I suspect the
same holds true for VB. Also, I explicitly set the COMVisible
attribute to true on the implemented interface methods. Also, if you
use the GUID generated in the project (as seen in Assembly
Information) that will screw things up. The interface and class need
separate GUIDs from the assembly. Just some suggestions. HTH. Bob
Rafał Giezgała - 23 Mar 2007 19:15 GMT
Each class and interface have different GUID and COMVisible == true.
Changing interface on _IExtraStuff didn't help.
bobahop@gmail.com - 23 Mar 2007 20:20 GMT
You have some things I don't have. For instance, I don't explicitly
set

[assembly: ClassInterfaceAttribute(ClassInterfaceType.None)]
or
ComSourceInterfaces(typeof(_IExtraStuff))

I do, however, set the ProgID

[ProgId("MyNamespaceName.MyClassName")]

HTH. Bob.
Rafał Giezgała - 26 Mar 2007 10:47 GMT
Yes I saw this part on one of example somewhere on the net. You can skip
this part. It doesn't change anything...unfortunately.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.