none
Problem with creating a COM DLL RRS feed

  • Question

  • Hi,

    I've tried to create a COM DLL in C# using VS 2008. I followed everything described here:
    - http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/09a6d6f1-2ce1-40f3-b8f4-1472b8343357
    - http://blog.stevedoria.net/20051008/creating-com-components-using-visual-csharp-dot-net

    The customer succeeds in adding the DLL as a reference in his project, but he can't see any of the methods/properties inside the class. The object browser shows the class, but it looks empty.

    This is my code:

    namespace MyNameSpace
    {
      [ComVisible(true)]
      public class Utility
      {
        public static void Init(string WSUrl)
        {
    //code here
        }
    
        public static Project GetProjectTemplate(string projectTypeID)
        {
    //code here
        }
    
        public static void CreateProject(Project p, string clientID)
        {
    //code here
        }
      }
    }
    

    In VB 6, we can go this far:

    Dim r As MyNameSpace.Utility
    Set r = New MyNameSpace.Utility
    r.Init "a_string_parameter"

    The project is built, but at runtime line 3 throws an exception: 438

    How can I solve this problem ?

    Thursday, June 17, 2010 8:07 AM

Answers

  • Hi,

    From what i can see all your methods marked as static. Static methods isn't accessable thru instance, they accessable thru type e.g. in C# MyNameSpace.Utility.Init("a_string_parameter"). So you'll need to remove static keyword. Hope this helps.


    Regards
    • Marked as answer by SamAgain Friday, June 25, 2010 10:21 AM
    Thursday, June 17, 2010 8:12 PM

All replies

  • Hi,

    From what i can see all your methods marked as static. Static methods isn't accessable thru instance, they accessable thru type e.g. in C# MyNameSpace.Utility.Init("a_string_parameter"). So you'll need to remove static keyword. Hope this helps.


    Regards
    • Marked as answer by SamAgain Friday, June 25, 2010 10:21 AM
    Thursday, June 17, 2010 8:12 PM
  • We temporarily mark a reply, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Please mark the right answer at right time.
    Thanks,
    Sam
    Friday, June 25, 2010 10:22 AM