473,321 Members | 1,877 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,321 software developers and data experts.

Assembly with shared __nogc class

I want to share a __nogc classes between different assemblies. For __gc
classes, one only needs to declare the class public in order to be able to
do this. Is there a way to share a __nogc class so that I can access its
members from different assemblies ? Should I just use __declspec(dllexport)
and __declspec(dllimport) or is there a different way ?
Nov 17 '05 #1
3 2263
Brandon Bray [MSFT] wrote:
Edward Diener wrote:
I want to share a __nogc classes between different assemblies. For
__gc classes, one only needs to declare the class public in order to
be able to do this. Is there a way to share a __nogc class so that I
can access its members from different assemblies ? Should I just use
__declspec(dllexport) and __declspec(dllimport) or is there a
different way ?
In 7.0, there is no way to do this. With the 7.1 compiler, the native
classes are public by default. For most people, this wasn't the
desired behavior. Hence, there is a compiler switch to make all
native types private to an assembly (at which point, there is no
solution to your problem again).


I am working with 7.1. I did use __declspec(dllexport) and
__declspec(dllimport) and a header file and it worked, but I think what you
are saying is that I need not have used that and could use #using and it
would still have worked.

It does seem as if the solution should be that __nogc classes are 'private',
just like normal non-.NET C++ classes in a DLL and:

1) One uses __declspec(dllexport) and __declspec(dllimport) and a header
file to access them
Or
2) The compiler recognizes a 'public' keyword for __nogc classes and allows
them to be exported and imported using .NET metadata just like __gc and
__value classes, and one uses #using to access them.

The type in the assembly doesn't actually have metadata (well, it has
next to no metadata). So, in order to use the type from another
assembly, a header file must say what to make of that type. #using
that type from an assembly, acts like a forward declaration for the
type.
I don't follow the above paragraph. Are you saying that if I had a #using
statement for my assembly which has __nogc classes that it would work
without needing to #include the header file ?

In Whidbey, we will allow you to write public and private on a native
class defintion.


Good idea !
Nov 17 '05 #2
Edward Diener wrote:
I don't follow the above paragraph. Are you saying that if I had a #using
statement for my assembly which has __nogc classes that it would work
without needing to #include the header file ?


No, the #using constitutes a forward declaration. A header file is still
needed to provide the class defintion.

--
Brandon Bray http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #3
Brandon Bray [MSFT] wrote:
Edward Diener wrote:
I don't follow the above paragraph. Are you saying that if I had a
#using statement for my assembly which has __nogc classes that it
would work without needing to #include the header file ?


No, the #using constitutes a forward declaration. A header file is
still needed to provide the class defintion.


Was my __declspec(dllexport) for my __nogc class upon building my assembly
and __declspec(dllimport) upon using my __nogc class unneeded, therefore,
since it was by default 'public' anyway ? Which compiler switch makes the
default 'private' for __nogc classes ? If I use that switch ( or IDE
setting ), could I not then use my
__declspec(dllexport)/__declspec(dllimport) technique to make select classes
'public', so to speak while retaining the option to have all other __nogc
classes private ?
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aurimas Norkevicius | last post by:
I have two web projects and a class library in the same solution. Both web projects uses class library dll. How to create a web setup project to install class library into client computers gac and...
0
by: Edward Diener | last post by:
Why is there a prohibition of instantiating __value type enums and classes within __nogc classes ? After all __value types are not managed by the GC and built-in __value types, such as 'int', are...
15
by: Edward Diener | last post by:
Why is it impossible to have a __value class instance variable in a __nogc class when it is possible to have a built-in type instance variable in a __nogc class ? __value class X { int a; };...
1
by: Ian Lazarus | last post by:
Hello, I tried to confirm that two different heap allocation calls were being made, i.e., one for __gc and one for __nogc. However, the addresses of the calls (as seen in disassembly) are not...
5
by: Chris Fink | last post by:
Using the GacUtil I created a SNK and deployed my assembly to the GAC using the GACUTIL. When browsing to c:\\Assembly I can see my custom assembly. However, how do I use it in a new project? I...
3
by: Stormy | last post by:
Can I define a template class as following #pragma unmanaged #include "mybaseclass.h" #pragma managed namespace mymanaged1 { namespace mymanaged2 { namespace myunmanaged
3
by: Shawnk | last post by:
I use two classes to manage the Main() command line (and alot of other stuff) for my prototyping environment. I tryed putting the MainClass in a DLL and just having the other class (which gets...
12
by: TC | last post by:
I'm trying to figure out what the "Friend" keyword does. I know it specifies that "elements are accessible from within the same assembly", but that doesn't help because I don't know what an...
2
by: =?Utf-8?B?TWluaS1Ub29scyBUaW1t?= | last post by:
I have an odd web services problem. I have a shared assembly (shared.dll) that is referenced both by a C# WinForms client (client.exe) and a C# Web Service (service.dll). When I upload the web...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.