开发者

Passing Dictionary Object from Classic ASP to C#

i'm calling a C# com interop dll from classic asp.

i want to send name value pairs to the c# dll.

tried using dictionary object in classic asp and accepting it using the same dictionary object (scripting.runtime com reference) in C#.

But it gives Invalid procedure call or argument error.

I got this idea of using scripting.dictionary from this link http://www.eggheadcafe.com/community/aspnet/2/10016705/is-there-any-way-to-pass-a-dictionary-object-to-c.aspx

may be im missing something

Questions

  1. am i missing something or is there a better way to pass key value pairs from Classic asp to C#.
  2. i'm also considering开发者_JAVA百科 using this library asp3tojson and deserializing in C#. is it too complicated?


I'd convert it to JSON. At least to know there are no object-level interoperability problems, especially when it comes to mixing in various MS objects.


Hi. It's possible to use System.Collections.HashTable (and many other from mscorlib) within asp classic applications.
Try the following. Hopefully useful.
Asp App:

Option Explicit
Dim Dictionary, objNetCom, i

Set Dictionary  = Server.CreateObject("System.Collections.HashTable")
Set objNetCom   = Server.CreateObject("MyTest.doTest")

With Dictionary
    For i = 65 To 90
        .Add Chr(i), i 
    Next
End With
Response.Write objNetCom.getDictType(Dictionary) 

Set Dictionary  = Nothing
Set objNetCom   = Nothing

a c# Com Visible:

using System;
using System.Collections;

namespace MyTest
{
    public class doTest
    {
        public string getDictType(Object tDict)
        {
            return String.Format("Type : \"{0}\", Count : {1}", ((Hashtable)tDict).GetType().ToString(), ((Hashtable)tDict).Count);
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜