469,921 Members | 2,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,921 developers. It's quick & easy.

Hide warning: "Generic classes may not be exposed to COM"

I am writing a COM in C# using visual studio 2005 and VSTO.
Inside the code I use some support classes that are generic but they are not
used in the inferface of the COM.
However I still get a number of warnings from the compiler like:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Mic rosoft.Common.targets :
warning : Type library exporter warning processing 'Utility.Array1D`1,
Test2003'. Warning: Type library exporter encountered a generic type.
Generic classes may not be exposed to COM."

Is there a way to hide these warnings?

Torben
Mar 1 '07 #1
5 10689
On Thu, 1 Mar 2007 14:14:37 +0100, "Torben Laursen" <To****@newsgroups.nospam>
wrote:
>I am writing a COM in C# using visual studio 2005 and VSTO.
Inside the code I use some support classes that are generic but they are not
used in the inferface of the COM.
However I still get a number of warnings from the compiler like:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Mi crosoft.Common.targets :
warning : Type library exporter warning processing 'Utility.Array1D`1,
Test2003'. Warning: Type library exporter encountered a generic type.
Generic classes may not be exposed to COM."

Is there a way to hide these warnings?

Torben
In your project properties open the Build Tab and either set the warning level
to something that will prevent the level of warnings you don't want to see, or
enter the warning number in the Suppress Warnings text box. Browse help for a
complete explanation of the Build Tab.

Do the above at your own risk....
Good luck with your project,

Otis Mukinfus

http://www.otismukinfus.com
http://www.arltex.com
http://www.tomchilders.com
http://www.n5ge.com
Mar 1 '07 #2
"Otis Mukinfus" <ph******************@phoney.comwrote in message
news:jp********************************@4ax.com...
On Thu, 1 Mar 2007 14:14:37 +0100, "Torben Laursen"
<To****@newsgroups.nospam>
wrote:
>>I am writing a COM in C# using visual studio 2005 and VSTO.
Inside the code I use some support classes that are generic but they are
not
used in the inferface of the COM.
However I still get a number of warnings from the compiler like:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\M icrosoft.Common.targets :
warning : Type library exporter warning processing 'Utility.Array1D`1,
Test2003'. Warning: Type library exporter encountered a generic type.
Generic classes may not be exposed to COM."

Is there a way to hide these warnings?

Torben
In your project properties open the Build Tab and either set the warning
level
to something that will prevent the level of warnings you don't want to
see, or
enter the warning number in the Suppress Warnings text box. Browse help
for a
complete explanation of the Build Tab.

Do the above at your own risk....
Good luck with your project,

Otis Mukinfus
Otis,

Thanks.

The warning that I get does not seems to have a number, or in the output
from the compiler it does not give one.

I could lower the warning level but I am a big fan of keeping it high.

Torben
Mar 1 '07 #3
Hi,

How did you mark your generic class?

What if you make them private or internal ?
--
Ignacio Machin
machin AT laceupsolutions com

"Torben Laursen" <To****@newsgroups.nospamwrote in message
news:O2*************@TK2MSFTNGP06.phx.gbl...
>I am writing a COM in C# using visual studio 2005 and VSTO.
Inside the code I use some support classes that are generic but they are
not used in the inferface of the COM.
However I still get a number of warnings from the compiler like:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Mic rosoft.Common.targets :
warning : Type library exporter warning processing 'Utility.Array1D`1,
Test2003'. Warning: Type library exporter encountered a generic type.
Generic classes may not be exposed to COM."

Is there a way to hide these warnings?

Torben

Mar 1 '07 #4
Ignacio,

The generic class is a small utility class that I use in bigger classes that
are public members of a C# dll.
It is maked as public.

If I mark the generic class as private I get a compiler error:
Namespace elements cannot be explicitly declared as private, protected, or
protected internal

I have not tryed to move the generic glass outside the namespace since I
prefere to keep all my code inside namespace's
If I mark the generic class as internal I get a large number of compiler
errors:
Inconsistent accessibility: field type 'Utility.Array1D<double>' is less
accessible than field 'BookKeeping.Phases_Base.Composition'

Torben

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:%2***************@TK2MSFTNGP06.phx.gbl...
Hi,

How did you mark your generic class?

What if you make them private or internal ?
--
Ignacio Machin
machin AT laceupsolutions com

"Torben Laursen" <To****@newsgroups.nospamwrote in message
news:O2*************@TK2MSFTNGP06.phx.gbl...
>>I am writing a COM in C# using visual studio 2005 and VSTO.
Inside the code I use some support classes that are generic but they are
not used in the inferface of the COM.
However I still get a number of warnings from the compiler like:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Mi crosoft.Common.targets :
warning : Type library exporter warning processing 'Utility.Array1D`1,
Test2003'. Warning: Type library exporter encountered a generic type.
Generic classes may not be exposed to COM."

Is there a way to hide these warnings?

Torben


Mar 1 '07 #5
Torben,
>Is there a way to hide these warnings?
Make sure you have the ComVisible(false) attribute at the assembly
level (for example in AssemblyInfo.cs), and then explcitly mark the
types you want to export to COM with ComVisible(true).
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 1 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by TheLetti | last post: by
1 post views Thread by Vicente Nicolau | last post: by
9 posts views Thread by Gomaw Beoyr | last post: by
2 posts views Thread by Jon Davis | last post: by
3 posts views Thread by Giggle Girl | last post: by
2 posts views Thread by morangolds | last post: by
4 posts views Thread by Peter K | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.