Microsoft KB Archive/197033

= PRB: Error "Cannot Create DLL Without COM Classes" =

Article ID: 197033

Article Last Modified on 8/25/2005

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



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.

