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

T

Torben Laursen

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\Microsoft.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
 
O

Otis Mukinfus

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\Microsoft.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
 
T

Torben Laursen

Otis Mukinfus said:
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
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

How did you mark your generic class?

What if you make them private or internal ?
 
T

Torben Laursen

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top