PRB: Error "Cannot Create DLL Without COM Classes" (197033)



The information in this article applies to:

  • Microsoft Visual J++ 6.0

This article was previously published under Q197033

SYMPTOMS

When you build a COM DLL project in Visual J++ 6.0, you get the following build error from the compiler:
Cannot create DLL without COM classes.

CAUSE

In one scenario, this error occurs when you create an ordinary project (not a COM DLL project) and later decide to package your class (or classes) as a COM DLL. The compiler sends the error when you select COM DLL packaging, but you do not designate any class (or classes) in your project as being a COM Class in the Project Properties on the COM tab. To fix this error, you can designate one or more of your classes as COM classes in the Project Properties on the COM tab. You can also choose another packaging option instead of COM DLL in the Project Properties on the Output Format tab under Packaging Type.

Another possible scenario that causes this error is when you have import statements between the @com.register comment tag declaration (in the class's header comments) and the declaration of the class. The following code demonstrates this:
   /**
    * @com.register (clsid=3E5B60A0-5492-11D2-AC57-0000F87A7A98)
    */ 
   import com.ms.wfc.*;
   public class Class1 {
   }
				
The compiler needs to have the @com.register comment tag immediately precede the Java class declaration to which it refers. Otherwise, the Java class is created as a standard Java class without COM attribute bytes. To fix this error, you need to move the import statement so that the @com.register comment tag immediately precedes the Java class declaration as follows:
   import com.ms.wfc.*;
   /**
    * @com.register (clsid=3E5B60A0-5492-11D2-AC57-0000F87A7A98)
    */ 
   public class Class1 {
   }
				

RESOLUTION

To resolve this problem, make sure that any @com.register comment tags immediately precede the Java class declaration. Also, make sure at least one or more of your classes are marked as COM classes if you are using COM DLL packaging.

STATUS

This behavior is by design.

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site: (c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Steve Horne, Microsoft Corporation.

Modification Type:MinorLast Reviewed:8/25/2005
Keywords:kberrmsg kbFAQ kbJavaFAQ kbprb KB197033