473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

5 New Member
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 1486
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Moderator Expert
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 New Member
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 Recognized Expert Expert
What kind of project is this? A library/dll project?
Oct 31 '07 #6
ssbae
5 New Member
What kind of project is this? A library/dll project?
It is a Class Library project.

Thanks.
Oct 31 '07 #7
Plater
7,872 Recognized Expert Expert
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 New Member
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 Recognized Expert Expert
Can you see all your classes in a managed code environment?
Nov 2 '07 #10

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

Similar topics

1
1379
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 many threads at the same time. What sort of things that I need to do to make sure the methods and the class are multi-thread safe? I thought I...
1
1623
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 code which works well. I understand the basic concept: our code is unmanaged, Windows Forms is Managed and Unmanaged may not call Managed code. I...
7
2905
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 database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of...
2
928
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 them. I've been playing with different options...using an interface, a function, passing variables between controls, etc. But it just occured to me...
11
2230
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 multithreaded operations. Any instance members are not guaranteed to be thread safe." I have 2 questions: 1. I thought dynamic variables are thread-safe...
1
1831
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 if you know what it is skip this paragraph), that is an abstract class, whose every function is public and purely virtual, and every field is...
2
7160
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 exposes one public class. I have some utilities classes that I would like to use in my public class but not expose to the end user. I was hoping...
41
13798
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 the Python idiom than one file per class. He asked why, and frankly, his valid question has me flummoxed. I tried to rationalize this Python...
2
1769
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 that stores objects of A and B. 2) A is at the lowest level and should "know about" only other As. B should know only about As and other Bs.
0
7455
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7962
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7814
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.