473,395 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Only one .cs file exposes its classes into .tlb file.

5
Hi~

I have two .cs files:

Class1.cs
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.     public class Class1
  4.     {
  5.         ...
  6.     }
  7.  
  8.     public class Class3
  9.     {
  10.         ...
  11.     }
  12.  
  13. }
  14.  
Class2.cs
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.     public class Class3
  4.     {
  5.         ...
  6.     }
  7. }
  8.  
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?
Oct 30 '07 #1
10 1479
Shashi Sadasivan
1,435 Expert 1GB
Hi~

I have two .cs files:

Class1.cs
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.     public class Class1
  4.     {
  5.         ...
  6.     }
  7.  
  8.     public class Class3
  9.     {
  10.         ...
  11.     }
  12.  
  13. }
  14.  
Class2.cs
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.     public class Class3
  4.     {
  5.         ...
  6.     }
  7. }
  8.  
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
Oct 30 '07 #2
ssbae
5
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
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.  
  4.     class Class2 
  5.     {
  6.         ...
  7.     }
  8. }
  9.  
Thank you anyway^^
Oct 30 '07 #3
Frinavale
9,735 Expert Mod 8TB
It's a typo.

The below is the corrected code.

Class2.cs
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.  
  4.     class Class2 
  5.     {
  6.         ...
  7.     }
  8. }
  9.  

Thank you anyway^^
Was the typo the problem?
Or are you still having problems?
Oct 30 '07 #4
ssbae
5
Was the typo the problem?
Or are you still having problems?
I still have the problem.

Sorry for the confusion.
Oct 30 '07 #5
Plater
7,872 Expert 4TB
What kind of project is this? A library/dll project?
Oct 31 '07 #6
ssbae
5
What kind of project is this? A library/dll project?
It is a Class Library project.

Thanks.
Oct 31 '07 #7
Plater
7,872 Expert 4TB
So I made a class library.
I set COM visible to (true)

I have the following:
Class1.cs
Expand|Select|Wrap|Line Numbers
  1. namespace mytemplib
  2. {
  3.     public class Class1
  4.     {
  5.         public int class1INT = 0;
  6.     }
  7.     public class Class3
  8.     {
  9.         public int class3INT = 0;
  10.     }
  11. }
  12.  
Class2.cs
Expand|Select|Wrap|Line Numbers
  1. namespace mytemplib
  2. {
  3.     public class Class2
  4.     {
  5.         public int class2INT = 0;
  6.     }
  7. }
  8.  
And after a build, I add the DLL as a reference to another project.
I can then get at:
Expand|Select|Wrap|Line Numbers
  1. mytemplib.Class1;
  2. mytemplib.Class2;
  3. mytemplib.Class3;
  4.  
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
Nov 1 '07 #8
ssbae
5
So I made a class library.
I set COM visible to (true)

I have the following:
Class1.cs
Expand|Select|Wrap|Line Numbers
  1. namespace mytemplib
  2. {
  3.     public class Class1
  4.     {
  5.         public int class1INT = 0;
  6.     }
  7.     public class Class3
  8.     {
  9.         public int class3INT = 0;
  10.     }
  11. }
  12.  
Class2.cs
Expand|Select|Wrap|Line Numbers
  1. namespace mytemplib
  2. {
  3.     public class Class2
  4.     {
  5.         public int class2INT = 0;
  6.     }
  7. }
  8.  
And after a build, I add the DLL as a reference to another project.
I can then get at:
Expand|Select|Wrap|Line Numbers
  1. mytemplib.Class1;
  2. mytemplib.Class2;
  3. mytemplib.Class3;
  4.  
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.
Nov 1 '07 #9
Plater
7,872 Expert 4TB
Can you see all your classes in a managed code environment?
Nov 2 '07 #10
balabaster
797 Expert 512MB
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]
Expand|Select|Wrap|Line Numbers
  1.  Namespace Namespace1 
  2.     <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
  3.     Public Class Class2
  4.         Public Const ClassId As String = "<Put unique GUID in here>"
  5.         Public Const InterfaceId As String = "<Put unique GUID in here>"
  6.         Public Const EventsId As String = "<Put unique GUID in here>"
  7.         Public Property2 As String
  8.         Public Sub New()
  9.             MyBase.New()
  10.         End Sub
  11.         Public Sub DoClassStuff()
  12.             MsgBox("Class2 is doing stuff")
  13.         End Sub
  14.     End Class
  15.     <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
  16.     Public Class Class3
  17.         Public Const ClassId As String = "<Put unique GUID in here>"
  18.         Public Const InterfaceId As String = "<Put unique GUID in here>"
  19.         Public Const EventsId As String = "<Put unique GUID in here>"
  20.         Public Property3 As String
  21.         Public Sub New()
  22.             MyBase.New()
  23.         End Sub
  24.         Public Sub DoClassStuff()
  25.             MsgBox("Class3 is doing stuff")
  26.         End Sub
  27.     End Class
  28. End Namespace
  29.  
Class2.vb
Expand|Select|Wrap|Line Numbers
  1.  Namespace Namespace1 
  2.     <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
  3.     Public Class Class1
  4.         Public Const ClassId As String = "<Put unique GUID in here>"
  5.         Public Const InterfaceId As String = "<Put unique GUID in here>"
  6.         Public Const EventsId As String = "<Put unique GUID in here>"
  7.         Public Property1 As String
  8.         Public Sub New()
  9.         End Sub
  10.         Public Sub DoClassStuff()
  11.             MsgBox("Class1 is doing stuff")
  12.         End Sub
  13.     End Class
  14. End Namespace 
  15.  
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# ;)
Nov 2 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
1
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...
7
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...
2
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...
11
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...
1
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...
2
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...
41
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.