开发者

Calling .NET exported method from classic ASP

This is strange. I was able to set up the environment so that I can call .NET method (via COM) from a classic ASP page.

Everything actually works as intended until when I have to call a .NET method that requires a .NET type.

So I have a method named

ApplyCategory(int subjectId, Category cat){...} And of course I have the Category type defined also.

In my classic asp page i have this:

dim categoryUtil, cat
set categoryUtil = Server.CreateObject("mydll.CategoryUtil")
set cat = Server.CreateObject("mydll.Category")
cat.id= 123
cat.property 开发者_高级运维= "so and so"
'...
categoryUtil.ApplyCategory(567, cat) ' I get this error here:
'Microsoft VBScript runtime error '800a0005' 
'Invalid procedure call or argument: 'ApplyCategory' 

What is wrong here? Is COM not recognizing the method signature of ApplyCategory? And how do I make the call correctly?


I think I figured it out.

For the record, here's what I did.

COM is not very good with method overriding in this context, so I had to change the signature for ApplyCategory from ApplyCategory(int, Category) to ApplyCategory(int, object)

and it worked.


I can't help you with the 'why', but I would recommend that the ApplyCategory() signature is changed so that it accepts two integers and not an integer and a category. The second integer would be the category id, and this would negate the need to pass the whole category.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜