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 / December 2004

Tip: Looking for answers? Try searching our database.

COM Interop 429-error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miro - 28 Dec 2004 10:39 GMT
Hello!

I've made a simple .NET .dll assembly which I deployed to another computer
through a Setup-project (.msi-file). I opened Visual Studio Basic 6.0 and
referenced the assembly. When I run the program it gives me: "Runtime Error
429 ActiveX Component can't Create Object". Doesn't the setup project
register the assembly correctly? I've tried both regsvr32 and regasm on the
assembly but with no luck.

This is my code.

.NET Assembly:

namespace NETtoCOM
{
    public class TestClass
    {
        public TestClass()
        {
        }

        public String Test()
        {
            return "Test";
        }
    }
}

VB6 program:

Private Sub Command1_Click()
   Dim netcl As NETtoCOM.TestClass
   Set netcl = New NETtoCOM.TestClass      <- error row
   MsgBox netcl.Test
End Sub

/Miro.NET Assembly
Phil Wilson - 28 Dec 2004 19:14 GMT
If you specify a GuidAttribute on the class you'll get a better idea about
whether the DLL is registered properly or not because you can look in the
registry. A typical problem here is that if you are not specific, the
compiler may change it, making your reference obsolete. The same is true of
assemblyversion - if you have 1.0.* it will change at every build and your
registration can become obsolete. Regsvr32 is the *wrong* tool to register a
.NET assembly with COM, it's regasm. In a VS setup project, the Register
property for the assembly determines registration. If it's set at
vsdrfDoNotRegister then no, it won't register the assembly. Internally, I
think the setup project runs regasm to get the registration data and store
it in the MSI file when you set the Register property.
Signature

Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

> Hello!
>
[quoted text clipped - 35 lines]
>
> /Miro.NET Assembly
Miro - 29 Dec 2004 08:41 GMT
Hello Phil!

I tried these changes:

I made an interface to my class and added a GUID (VS/Tools/Create GUID). It
now looks as follows:

namespace NETtoCOM
{
    public interface ITestClass
    {
        String Test();
    }

    [GuidAttribute("E0EBB103-BCDB-4dd6-B0AB-1B67967B72A8")]

    public class TestClass : ITestClass
    {
        public TestClass()
        {
        }

        public String Test()
        {
            return "Test";
        }
    }
}

In the Project property pages, under Configuration properties, I found a
property "Register for COM Interop". This was set to true even before. Is
there another registry property that has to be set?

Anyway, I uninstalled and installed the assembly and looked for the GUID in
the registry. No match, but I still could reference it from VB6 (Still got
the 429 error). I then used regasm and successfully registered and found the
assembly/GUID in the registry. I've created a new VB6 project and got this
error:

Run-Time error: The File or assembly NETtoCOM or one of its dependencies was
not found.

I ran depends.exe and got two warnings regarding the files Apphelp.dll and
MPR.dll. I found out that the Apphelp.dll was XP-specific and should not be
installed on win 2000. Is it possible to disable it from the assembly? The
second warning was the same as on my dev comp:

"At least one module has an unresolved import due to a missing export
function in a delay-load dependent module." It seems to be error with the
WNetRestoreConnectionA function

/Miro

> If you specify a GuidAttribute on the class you'll get a better idea about
> whether the DLL is registered properly or not because you can look in the
[quoted text clipped - 46 lines]
> >
> > /Miro.NET Assembly
Phil Wilson - 29 Dec 2004 19:11 GMT
What you should see in the registry is an entry in HKCR\CLSID\{Your class
guid}\InprocServer32 that points to mscoree.dll and with the assembly name,
assembly attributes and class name of your COM class. Make sure those
attributes match the actual assembly. If you didn't run regasm with
/codebase, the assembly needs to be in the GAC or next to the VB6 exe. 429
is unfortunately too generic.  An actual HRESULT would tell you whether you
have a COM registration error or a .NET class instantiation error (such as
your .NET code crashing in your class constructor).

Register for COM interop is a VS compile setting, it's got nothing to do
with generation of an MSI file via a setup project.  The Register setting
I'm referring to is in your setup project. Select the assembly, F4 and look
at properties.
Signature

Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

> Hello Phil!
>
[quoted text clipped - 111 lines]
>> >
>> > /Miro.NET Assembly
Scott C. Reynolds - 29 Dec 2004 20:03 GMT
> What you should see in the registry is an entry in HKCR\CLSID\{Your class
> guid}\InprocServer32 that points to mscoree.dll and with the assembly name,
[quoted text clipped - 9 lines]
> I'm referring to is in your setup project. Select the assembly, F4 and look
> at properties.

Funny, I just blogged this exact thing:
http://www.scottcreynolds.com/PermaLink.aspx?guid=82d984cf-c9c1-4231-aa51-e3f213
5065e1

 for a full description.  But you also need to add the ClassInterface
attribute, and depending on the binding you want to support, set it to
AutoDispatch or AutoUnknown.

Scott.

Signature

____________________________________________
Scott C. Reynolds - Tales From the SharpSide
http://www.scottcreynolds.com
scott@scottcreynolds.com

*****Get your SharpSide Swag!******
http://www.cafepress.com/sharpside/
***********************************

Miro - 30 Dec 2004 09:53 GMT
Thanks for all your help.

It seems like strong-naming the assembly and running regasm with the
/codebase parameter made the difference.

I found the registry property and it was set to vsdrfCOM. I'm going to try
out the vsdrfCOMSelfReg. If I'm right, this would save me from running Regasm
after installation?

Thanks again
Miro

> > What you should see in the registry is an entry in HKCR\CLSID\{Your class
> > guid}\InprocServer32 that points to mscoree.dll and with the assembly name,
[quoted text clipped - 17 lines]
>
> Scott.
Phil Wilson - 30 Dec 2004 16:58 GMT
That self-reg setting won't work. It's intended for traditional COM servers
that have a DllRegisterServer entrypoint - your assembly doesn't.
You shouldn't need to run regasm after the installation. The register
property should have a setting vsdraCOM that should do the equivalent of
running regasm.
Signature

Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

> Thanks for all your help.
>
[quoted text clipped - 38 lines]
>>
>> Scott.

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.