By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,315 Members | 1,736 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,315 IT Pros & Developers. It's quick & easy.

Managed DLL -- Don't want all Public __gc Classes available

P: n/a
Using VS.net 2003 / Managed C++

I have created a base object (public __gc CBaseObject)
that everything in my project inherits from (Similar to
how everything really inherits system::Object).
I have a Heap class that I have made into a DLL. In this
dll, I include CBaseObject (I have to dynamic cast to it
for access to some of its functions). This is made into a
dll for use in several other projects. However, when I
include (I guess #using is more like it) the dll, the
object browser lists the CHeap class (Should be there) AND
the CBaseObject class (Should NOT be there).

The problem arises when one of my projects that uses this
dll also includes CBaseObject. I get a Redefinition
error. I tried to make CBaseObject to private __gc
CBaseObject (the DLL then doesn't list CBaseObject) , but
then other
errors came up (The Heap DLL would compile fine, but when
I used it, any functions or member variables that use or
referance
CBaseObject would fail). Also, there was a warning when I
compiled the CHeap Dll (Something to the effect of can't
use private object outside of the local assembly, not sure
the exact wording).

How can I prevent CBaseObject from being available to any
projects that use the CHeap DLL?? IE, how can I control
what classes are exposed in a Managed DLL?? __Private
doesn't work, but is there something else that will??

thanks ahead

GE

PS> I am aware of the exports function for Dlls, but I am
writing a managed DLL to get away from this. I'll also
get some of the exact error messages and post them here
later.
..
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You cannot define the same type in multiple assemblies and have it work
correctly. For these types that you want to reuse you need to out them in a
separate assembly and reference that assembly whenever you need it.

Note that in the next release the compiler will give an error when you have
a private base type for a public managed type, that is illegal in practical
CLR terms.

Ronald Laeremans
Visual C++ team

"Geoff Hilyard" <gd*********@regaldecision.com> wrote in message
news:09****************************@phx.gbl...
Using VS.net 2003 / Managed C++

I have created a base object (public __gc CBaseObject)
that everything in my project inherits from (Similar to
how everything really inherits system::Object).
I have a Heap class that I have made into a DLL. In this
dll, I include CBaseObject (I have to dynamic cast to it
for access to some of its functions). This is made into a
dll for use in several other projects. However, when I
include (I guess #using is more like it) the dll, the
object browser lists the CHeap class (Should be there) AND
the CBaseObject class (Should NOT be there).

The problem arises when one of my projects that uses this
dll also includes CBaseObject. I get a Redefinition
error. I tried to make CBaseObject to private __gc
CBaseObject (the DLL then doesn't list CBaseObject) , but
then other
errors came up (The Heap DLL would compile fine, but when
I used it, any functions or member variables that use or
referance
CBaseObject would fail). Also, there was a warning when I
compiled the CHeap Dll (Something to the effect of can't
use private object outside of the local assembly, not sure
the exact wording).

How can I prevent CBaseObject from being available to any
projects that use the CHeap DLL?? IE, how can I control
what classes are exposed in a Managed DLL?? __Private
doesn't work, but is there something else that will??

thanks ahead

GE

PS> I am aware of the exports function for Dlls, but I am
writing a managed DLL to get away from this. I'll also
get some of the exact error messages and post them here
later.
.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.