开发者

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

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开发者_StackOverflow社区 GetObj = Obj.dotnetMethod(inputStr)
SET Obj = NOTHING
End Function

The problem that i am facing is that when i passs inputStr to the obj.dotnetMethod, it is not recognising the string that i am passing from the asp page and it doesn't return to me any result which it should.


Could be a unicode problem--.Net expects unicode strings. ASP, I believe, does not.

But if you aren't even sure the method is registered, well then you have to make sure that dll is COM visible. ASP is a world that doesn't know anything about managed code or .Net. You have to use COM. You know, old school regsvr32, or ASP won't find it.


I can guess at a couple of things the might be going wrong (your question really needs more detail)

Set GetObj = Obj.dotnetMethod(inputStr)
  • dotnetMethod returns a String, DateTime or a primitive type such Int32 in which case you should remove the Set keyword.
  • dotnetMethod is return an object that isn't ComVisible itself.

BTW,

Set inputStr = Nothing
inputStr = "myString"

Why set inputStr to Nothing and then assign a string to it??

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜