Geeks With Blogs
No Fun Intended Shoo! You are debugging the crap outta me!
I am having problems getting a .NET Assembly that I have developed to play nice with ASP. It is driving me crazy. Here is what I have done so far:

1. I have created a strong name key file for the assembly.
2. I have referenced the key file in AssemblyInfo.cs.
3. I have specified that the assembly should be registered for COM interop.
4. I have added ProgId, ClassInterface, and IDispatchImpl attributes to the classes that should be registered.
5. The entry class has a default constructor (no arguments).
6. Set the ComVisible attribute on each method to true/false appropriately.

So, when I compile the assembly, it does fine and I get no errors. The component is registered appropriately. I can see the component as a com object. However, when I instantiate the object, there are no methods or properties available. What the heck am I missing? I am sure it is something stupid but for the life of me I cannot figure it out. Posted on Monday, March 28, 2005 10:30 AM .NET | Back to top


Comments on this post: Use of .NET Assemblies as COM objects - HELP ME

# re: Use of .NET Assemblies as COM objects - HELP ME
Requesting Gravatar...
I did it this way: Added

[System.Runtime.InteropServices.GuidAttribute("someguidimade")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]

to the class to be registered, did the strong name, and that was basically it.

The thing works from VB, but it does not support intellisense in VB. Is that your problem? The intellisense? Or does it not physically work?
Left by Scott C. Reynolds on Mar 28, 2005 11:45 AM

# re: Use of .NET Assemblies as COM objects - HELP ME
Requesting Gravatar...
We solved it by adding this to a com visible class:

<ComClass(ExternalFileInterface.ClassId, ExternalFileInterface.InterfaceId)> Public Class ExternalFileInterface


#Region "CLSID"
'Should be generated for every class
Public Const ClassId As String = "36B18F94-F96C-4ab8-8F00-87E912889EEA"
Public Const InterfaceId As String = "088D404A-3927-4b40-BB3C-456C88FDA852"
#End Region

If you do this your class is visible in the object browser and you have intellisense.
Left by Johan Gillis on Mar 30, 2005 2:12 AM

# re: Use of .NET Assemblies as COM objects - HELP ME
Requesting Gravatar...
Okay, it physically did not work but it is working now. I went through two different paths: first, I created an interface for each of my physical classes that needed to be exposed and added a Guid for each interface. This worked well for methods, not so for properties. So, I changed the ClassInterfaceType to AutoDual and added a ProgId attribute to the top of the class and it suddenly started working. Keep in mind that Intellisense was NOT my problem, it was not working. Finally, it is working.
Left by Jason Bentley on Mar 30, 2005 3:59 PM

Your comment:
 (will show your gravatar)


Copyright © Jason Bentley | Powered by: GeeksWithBlogs.net