Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2005, 02:40 AM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default .NET in COM

Hi

I'm trying to use a .Net User Control in a VB6 Form.

I've created the control, as a class of a class library, adding references to System.Windows.Form. The class inherits from UserControl and implent an interface that is suposed to expose the control's methods to com:

Class declaration:

<GuidAttribute("8DFE85EE-604A-4350-B4FC-8B6E97CC1A08"), _
ClassInterface(ClassInterfaceType.None)> _
Public Class UserControl1
    Inherits System.Windows.Forms.UserControl
    Implements IUserControl1

'Constructor and initialize components

public function doSomething() as string
return "hello"
end function

End Class


' Interface

Imports System.Runtime.InteropServices
<InterfaceTypeAttribute(ComInterfaceType.Interface IsIUnknown)> _
Public Interface IEJSimple
function doSomething() as string
End Interface


Then i execute de tlbexp and regasm commands and create a new project in visual basic 6 with reference to the tlb generated with tlbexp.

with this code:

Private Sub Form_Load()
Dim o As Object
Set o = Me.Controls.Add("mySolution.UserControl1", "o")
o.Visible = True
End Sub

I can add the control to the VB6 form i'm not able to call the doSomething() method. The error i get is "the object does not admit that property or method(error #438)"

I also tried to add the control to the VB form as follow:

Dim o As mySolution.UserControl1
Set o = Me.Controls.Add("mySolution.UserControl1", "o")

But i get a type missmatch error.

¿What is wrong with this o what i'm forgetting?


Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I run VB .net 2005 with DOT NET 2003 APPLICATI kadesskade BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 2 August 8th, 2006 05:14 AM
Database diagram in .net using asp.net,c#.net scotttiger ADO.NET 2 February 16th, 2005 01:35 AM
Beginning ASP.Net Databases Using VB.Net ISBN 6195 tlamazares SQL Server ASP 1 December 15th, 2003 01:28 PM
CR.net With ASP.net using C#.net Nilesh Leuva Crystal Reports 1 September 11th, 2003 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.