tags:

views:

27

answers:

2

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

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.

A: 

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.

Plynx
I have already set ComVisible=true in my .Net DLL. Because of that, ASP is able to call the method using the .net dll object
flopdix
Any help? Please let me knwo, i am stuck.
flopdix
Nope, strings in ASP/VBScript are Unicode (that is the UTF-16 2 bytes per character code points) the same as .NET strings.
AnthonyWJones
A: 

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??

AnthonyWJones