using vb6 component ?

Hi,

Is there a way to use vb6 components in C#, just like in old asp (Server.CreateObject)...

I tried with Activator.CreateInstance but didn't worked...is continue to as kfor the reference...




Answer this question

using vb6 component ?

  • Lintubird

    The exception I sent you, I think that the problem is not with the cast, but with the way The method of the com+ object is called...

  • Tamiri

    c is null....how can I use POC

    I'm calling the method just like in vb6 the function inside de dll, with the 2 parameters !



  • Oz22

    OK, Now it worked..

    Type objAddType = Type.GetTypeFromProgID("ACEGAC.clsAdmDBConsultas");

    //Create Instance

    object objConsultas = Activator.CreateInstance(objAddType);

    //Make Array of Arguments

    object[] myArguments = { 1 };

    object c;

    c = objAddType.InvokeMember("ConsultarAgendamento", BindingFlags.InvokeMethod, null, objConsultas, myArguments);

    MessageBox.Show(c.ToString());

    But there is still a problem, how can I make to show the values of the c object...

    Like in VB6 it returns a recordset....

    Thanks for helping again.



  • moniker

    POC I mean to say, you create your own dll in VB (as you do not have access to the current one) and add a test method in that which might return a simple string. Then check if it is able to return the string value in your c# code.. hope you are getting me....

  • Robert3234

    Those articles are not helping you

    What is hapening if you create reference of ADODB and typecast your object"c" to that



  • FC-Shiro

    Nops.... The object keeps null..

  • ne_plus_ultra

    Hey, I am back again!!!

    Have a look at following article

    http://www.codeproject.com/csharp/usecomappincs.asp

    The late binding section should help.

    Excerpt for the article

  • We have Get IDispatch Interface using Type.GetTypeFromProgID("Project1.Class1")
  • We have to create instance using the type ID Activator.CreateInstance(objAddType)
  • We have to make array of arguments (if required)
  • Invoke the Method using objAddType.InvokeMember function.


  • PsychUK

    I am at work and not having MSN (good that I have access to msdn). And I do not have VB6 too... so I am not able to create dll :-( ......

    Are you able to return simple value (not the record set) from the dll in c#



  • satish_k

    Good Morning!!

    Have you able to get the desired results According to you what could be the reason of the exception. You said, it is not about casting, right. Have you able to figureout something.



  • Eitan Shapir

    Fom dll, in vb6 yes, from the C# directly yes...... But from the DLL in vb6 through C# I can't....and for security reasons in the client side I can't connect directly to the database...Damm it...=)



  • MarcNelson

    OK,

    It gives me this exception "An exception was added by the destiny of a call", lol....I think I'm gonna give up...

    Too difficult to do that



  • sideswipe

    objConsultas is null or "c" is null If c is null, are you sure we are invoking the object method properly. Have you tried creating POC and getting the result from your test method

  • Hughsieman

    This is the way I'm using to test... I created my own...And I'm trying to get the result as the original one might do....

    Do you have MSN I can send you the files if you want to try...

    Or if you can...make a test there.... Create a dll in vb6 to select a value from SQL Server...and return it as string.....test in another vb project...IF it's working try to use the code I post to get it's value...



  • Atul Bahl

    I think for that you need to typecast/convert object "c" to appropriate type. In your case it is recordset which is getting return.

    Hope following article helps you

    http://support.microsoft.com/kb/308611

    and
    http://support.microsoft.com/kb/313330



  • using vb6 component ?