Pass string from ASP Page (using vbscript) to C# DLL function as input parameter [Answered]RSS

6 replies

Last post Mar 08, 2010 06:38 AM by flopdix

  • Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 12:17 PM|flopdix|LINK

    I am trying to achieve this but this is not working. I am sure i am missing something, please help me where i am wrong. I hope this is achievable. We should able to pass a string from ASP Page (using vbscript) to c# dll ( have this dll stored in gac and i have already registered it using regasm utility).

    Below is my code:

    Function GetObj()
    Set Obj = Server.CreateObject("namespace.classname")

    Set inputStr = Nothing
    inputStr
    = "myString"

    Set
    GetObj = Obj.dotnetMethod(inputStr)
    SET Obj = NOTHING
    End
    Function

    Please help. Waiting.

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 02:05 PM|tomkmvp|LINK

    It would be much easier to help if you explained what "not working" means?  What happens exactly?  Is there an error message?

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 02:25 PM|flopdix|LINK

    yes i am getting error - "Wrong number of arguments or invalid property assignment".

    Looks like the .Net dll method (which accepts string variable), is not recognising the string that i am passing from my asp page.

     I have also ensured that ComVisible = true in AssemblyInfo.cs file of my .net dll.

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 03:15 PM|tomkmvp|LINK

    flopdix

    Set inputStr = Nothing

    Taking a guess but this may be your problem.  I think that assigns inputStr as an object.

    What happens if you just do this?

    Set GetObj = Obj.dotnetMethod("myString")

    Also, does you method return a string or obejct?  or nothing?

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 03:24 PM|flopdix|LINK

    I already tried doing this but it gives me error -- "object required [string "myString"]"

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 05, 2010 04:00 PM|tomkmvp|LINK

    I know that ASP handles everything as a "variant" type and I suspect that may be the issue here.  You may get better answers in a developer forum (http://forums.asp.net/ perhaps?)

  • Re: Pass string from ASP Page (using vbscript) to C# DLL function as input parameter

    Mar 08, 2010 06:38 AM|flopdix|LINK

    Just to share, i was able to fix this issue by using COM Interop services in .net.

    What i did was, in the .Net DLL method, that accepts string as the input parameter, i marshalled it using the UnManagedType.BStr which is COM compatible string to accept the string as in the format of Classic ASP or VB Script.

    void myMethod ([In, marshalas unmanagedtype.BStr], string inputParam) {}