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

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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.