COM+ Typelib fields missing

I created a VB .NET DLL that I wanted to expose to COM+.  I found some info on the web on how to do that and it worked great.  That was in VS 2003 with framework 1.1

Now I need to rewrite one of the private functions in the dll.  Seems pretty easy to do.  However I'm using VS2005 and framework 2.0 .  After rebuilding the DLL the typelib is way different.  All the public fields I had in the prior version are not in the new typelib.

After a long time I figured out what the issue is.  The original had this attribute

<Assembly: ClassInterface(ClassInterfaceType.AutoDual)>

I thought that VS2005 would use the attribute too.  But when I look at the compiled DLL with Reflector the classinterface attribute is missing so the framework generates a new interface leaving out the Public fields.

For each class I had to explicity include this

<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)> _

I understand that Public fields (aka variables) are bad programming and that AutoDual should never be used, but I don't feel like converting all of these variables to properties AND creating an interface for each of the classes.  There are 30 classes and I've had to change them once in 5 years.

Print | posted on Friday, January 9, 2009 10:06 AM