Hi~
I have two .cs files:
Class1.cs -
namespace ClassLibrary1
-
{
-
public class Class1
-
{
-
...
-
}
-
-
public class Class3
-
{
-
...
-
}
-
-
}
-
Class2.cs -
namespace ClassLibrary1
-
{
-
public class Class3
-
{
-
...
-
}
-
}
-
Also I set [assembly: ComVisible(true)] and check the "Register for COM interop" on the project property.
The problem is that the .tlb file created by Visual Studio 2005(and tlbexp.exe) has only interfaces and coclasses have been defined in Class1.cs file.
i.e., Class1 and Class3 are shown in the .tlb file, but Class2 is not shown in the .tlb file.
What did I wrong?
10 1479
Hi~
I have two .cs files:
Class1.cs -
namespace ClassLibrary1
-
{
-
public class Class1
-
{
-
...
-
}
-
-
public class Class3
-
{
-
...
-
}
-
-
}
-
Class2.cs -
namespace ClassLibrary1
-
{
-
public class Class3
-
{
-
...
-
}
-
}
-
Also I set [assembly: ComVisible(true)] and check the "Register for COM interop" on the project property.
The problem is that the .tlb file created by Visual Studio 2005(and tlbexp.exe) has only interfaces and coclasses have been defined in Class1.cs file.
i.e., Class1 and Class3 are shown in the .tlb file, but Class2 is not shown in the .tlb file.
What did I wrong?
because there is actually no class 2?
you have defined class 3 twice in both the files!!
if its a typo...i havent touched what you are trying to do, good luck
because there is actually no class 2?
you have defined class 3 twice in both the files!!
if its a typo...i havent touched what you are trying to do, good luck
It's a typo.
The below is the corrected code.
Class2.cs -
namespace ClassLibrary1
-
{
-
-
class Class2
-
{
-
...
-
}
-
}
-
Thank you anyway^^
It's a typo.
The below is the corrected code.
Class2.cs -
namespace ClassLibrary1
-
{
-
-
class Class2
-
{
-
...
-
}
-
}
-
Thank you anyway^^
Was the typo the problem?
Or are you still having problems?
Was the typo the problem?
Or are you still having problems?
I still have the problem.
Sorry for the confusion.
What kind of project is this? A library/dll project?
What kind of project is this? A library/dll project?
It is a Class Library project.
Thanks.
So I made a class library.
I set COM visible to (true)
I have the following:
Class1.cs -
namespace mytemplib
-
{
-
public class Class1
-
{
-
public int class1INT = 0;
-
}
-
public class Class3
-
{
-
public int class3INT = 0;
-
}
-
}
-
Class2.cs -
namespace mytemplib
-
{
-
public class Class2
-
{
-
public int class2INT = 0;
-
}
-
}
-
And after a build, I add the DLL as a reference to another project.
I can then get at: -
mytemplib.Class1;
-
mytemplib.Class2;
-
mytemplib.Class3;
-
just fine.
If you are trying to use them as COM objects, I think you need to create more GUIDs for them maybe? I'm not real clear on how to use them as COM (never really done it) so I don't know
So I made a class library.
I set COM visible to (true)
I have the following:
Class1.cs -
namespace mytemplib
-
{
-
public class Class1
-
{
-
public int class1INT = 0;
-
}
-
public class Class3
-
{
-
public int class3INT = 0;
-
}
-
}
-
Class2.cs -
namespace mytemplib
-
{
-
public class Class2
-
{
-
public int class2INT = 0;
-
}
-
}
-
And after a build, I add the DLL as a reference to another project.
I can then get at: -
mytemplib.Class1;
-
mytemplib.Class2;
-
mytemplib.Class3;
-
just fine.
If you are trying to use them as COM objects, I think you need to create more GUIDs for them maybe? I'm not real clear on how to use them as COM (never really done it) so I don't know
Thank you.
But the problem is going on.
Can you see all your classes in a managed code environment?
Thank you.
But the problem is going on.
Okay, my demonstration possibly shows what you are missing:
[size=2][color=#0000ff][/color][/size][size=2][color=#0000ff][/color][/size]
[size=2][color=#0000ff]Class1.vb[/color][/size] - Namespace Namespace1
-
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
-
Public Class Class2
-
Public Const ClassId As String = "<Put unique GUID in here>"
-
Public Const InterfaceId As String = "<Put unique GUID in here>"
-
Public Const EventsId As String = "<Put unique GUID in here>"
-
Public Property2 As String
-
Public Sub New()
-
MyBase.New()
-
End Sub
-
Public Sub DoClassStuff()
-
MsgBox("Class2 is doing stuff")
-
End Sub
-
End Class
-
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
-
Public Class Class3
-
Public Const ClassId As String = "<Put unique GUID in here>"
-
Public Const InterfaceId As String = "<Put unique GUID in here>"
-
Public Const EventsId As String = "<Put unique GUID in here>"
-
Public Property3 As String
-
Public Sub New()
-
MyBase.New()
-
End Sub
-
Public Sub DoClassStuff()
-
MsgBox("Class3 is doing stuff")
-
End Sub
-
End Class
-
End Namespace
-
Class2.vb - Namespace Namespace1
-
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
-
Public Class Class1
-
Public Const ClassId As String = "<Put unique GUID in here>"
-
Public Const InterfaceId As String = "<Put unique GUID in here>"
-
Public Const EventsId As String = "<Put unique GUID in here>"
-
Public Property1 As String
-
Public Sub New()
-
End Sub
-
Public Sub DoClassStuff()
-
MsgBox("Class1 is doing stuff")
-
End Sub
-
End Class
-
End Namespace
-
Further reading is also available here: http://support.microsoft.com/kb/817248
It demonstrates all the steps you need to follow in order to make a component visible to VB6 (i.e. via a COM interface).
Obviously you'll need to translate to C# ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Zeng |
last post by:
Hello,
If I have an object that exposes many methods which don't change anything
about the object (at least I'm not aware in terms of implementation of the
..net class). The methods are called...
|
by: Sparhawk |
last post by:
Hi,
my company is going to migrate a large VC++ application to .NET to
make use of Windows Forms (the old class library is not updated any
more). We are not planning to migrate the rest of the...
|
by: jsale |
last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app
i have made is running on IIS v6 and consists of a number of pages that allow
the user to read information from the...
|
by: darrel |
last post by:
This is a follow up to a semi-regular question I've had off and on.
The main question is how to get one set of variables from an XML file so
that various usercontrols on the page can all use...
|
by: dee |
last post by:
OleDbCommand class like many .NET classes has the following description in
its help file:
"Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for...
|
by: jbzdak |
last post by:
Recently, I have been learning Java (it is one of laboratories on my
department), well I know Java is awfully slow, but it is not the point
that I'm interested.
Java has a keyword "interface. (and...
|
by: google |
last post by:
Is it possible to add a class, coded within a separate .cs file, that
is available only within the project?
I hope that is clear. In more detail - I want to write a DLL for
distribution that...
|
by: Chris Lasher |
last post by:
A friend of mine with a programming background in Java and Perl places
each class in its own separate file in . I informed him that keeping
all related classes together in a single file is more in...
|
by: fgh.vbn.rty |
last post by:
Hi,
I'm not sure if i'm asking the question correctly but anyway here it
is.
Say I have 3 classes - class A, class B, class R.
1) A and B are the building blocks and R is like a repository...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |