XML comment problem with [ClassInterfaceAttribute(...

R

RickyJack

Using XML comments with the following code works correctly:

using System;
using System.Runtime.InteropServices;
namespace test
{
//[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
/// <summary>Summary description for temp1.</summary>
public class temp1
{
/// <summary></summary>
public temp1() {}
}
}

However, if I uncomment the "//[ClassInterfaceAttribute" line, I get
the following XML comment build errors:

XML comment is not placed on a valid language element
Missing XML comment for publicly visible type or member 'test.temp1'

I need to specify the [ClassInterfaceAttribute so that I can use this
class as a COM component.

Any ideas on how to get XML comments as well as COM Interop??

Thanks,
Rick Webster
 
C

Chris J. Breisch

I suspect that you'd need your comments above the attribute and not below
it.


-chris

Using XML comments with the following code works correctly:

using System;
using System.Runtime.InteropServices;
namespace test
{
//[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
/// <summary>Summary description for temp1.</summary>
public class temp1
{
/// <summary></summary>
public temp1() {}
}
}

However, if I uncomment the "//[ClassInterfaceAttribute" line, I get
the following XML comment build errors:

XML comment is not placed on a valid language element
Missing XML comment for publicly visible type or member 'test.temp1'

I need to specify the [ClassInterfaceAttribute so that I can use this
class as a COM component.

Any ideas on how to get XML comments as well as COM Interop??

Thanks,
Rick Webster
 
G

Grant Richins [MS]

Reverse the order of the XML comment and the attribute. Quoting from the
language spec (Appendix B) "They must immediately precede a user-defined
type (such as a class, delegate, or interface) or a member (such as a field,
event, property, or method) that they annotate. Attribute sections (§17.2)
are considered part of declarations, so documentation comments must precede
attributes applied to a type or member."

So your code should look like this:
using System;
using System.Runtime.InteropServices;
namespace test
{
/// <summary>Summary description for temp1.</summary>
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class temp1
{
/// <summary></summary>
public temp1() {}
}
}
 
R

RickyJack

Grant Richins said:
Reverse the order of the XML comment and the attribute...

Thanks for the help! Reversing the lines worked. I guess I should have
tried that but I was under the assumption that the XML comment stuff
had to be directly before the class definition.

Regards,
Rick Webster
 

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