none
VB6 calling a C# dll

    Pregunta

  • Hi all,

    I am trying to call a c# dll from VB6.

    I could able to add the refernece for the dll but I am not able to access the methods of the dll.

    What could be the reason?

    I registered the dll using the regasm and .tlb is also generated.

    If any one could help me.

     

    Regards,

    Santha

     

    viernes, 22 de diciembre de 2006 10:39

Respuestas

  • Hi All,

    I could able to call the C# dll from VB6.

    even if the methods are not coming I could able to call the methods from VB, it is only the intellisense which was not working.

    Once I added the attribute classinterfacetype to none in my C# class that intellisense also came.

    Regards,
    Santha

    martes, 09 de enero de 2007 12:50

Todas las respuestas

  • This forum is for .NET, not VB6

    Download .NET and then do this in VB.NET 2005:

    My Project -> References -> Add... -> Browse...

    Then select your DLL.

    In your main code, add Imports <NamespaceName>.<SubName(s)> above the class declaration.

    Then begin coding!

    viernes, 22 de diciembre de 2006 14:43
  • This is because C# will create a .NET CLass Library and not a COM Class Library.  VB6 knows only about COM Class Libraries.    So if you have the C# project you can make it a COM DLL's which then would be visible to VB6.

     

    viernes, 22 de diciembre de 2006 16:03
  • Thanks spotty

    I have created the class in C# and made it as ComVisible using the "ComVisible" attribute.

    I have set the "Register for COM interop" property of the project.

    I could able to add the reference of that project in VB and create an instance of that class but I could not able to call the methods in that class.

    Why is this behavior?

    Is there anything I am missing?

    Regards,

    Santha

    jueves, 28 de diciembre de 2006 5:25
  • SanthaMind,

    I think it is rather strange that call the C# reference in VB6. What do you think? First of all, they are not run on the same framework, and I want to mention you that the .NET Framework is totally different from the VB6 COM. Sometimes the convert or reference inropration between the .NET and other dll file will cause the edition conflict. The reason maybe a little complex, however, I think you had better transfer your VB6 project to the .NET Framework, then you can try to add a reference of C# code in your project.

    jueves, 04 de enero de 2007 10:07
  • Are the methods marked as public?

    Hope this helps,

    viernes, 05 de enero de 2007 5:15
  • Hi All,

    I could able to call the C# dll from VB6.

    even if the methods are not coming I could able to call the methods from VB, it is only the intellisense which was not working.

    Once I added the attribute classinterfacetype to none in my C# class that intellisense also came.

    Regards,
    Santha

    martes, 09 de enero de 2007 12:50