Для вещей, как тривиальные методы get и методы set, совместно используют комментарий между тогда и описывают цель свойства, не метода get/метода set.
/**
* Get foo
* @return The value of the foo property
*/
int getFoo() {
return foo;
}
не полезны . Лучше сделайте что-то как:
/**
* Get the current value of the foo property.
* The foo property controls the initial guess used by the bla algorithm in
* {@link #bla}
* @return The initial guess used by {@link #bla}
*/
int getFoo() {
return foo;
}
И да, это - больше работы.
I was able to get this working by doing the following:
Create a new C# dll in VS 2010.
namespace st4
{
public class st4_functions
{
public int GetValue()
{
return 34;
}
}
}
In QTP I added the following lines:
Set obj = DotNetFactory.CreateInstance("st4.st4_functions", "c:\\st4.dll")
MsgBox obj.GetValue()
Thanks to all that responded to my problem. Though I did not do the COM solution, it got me thinking that I could stay with .NET and led to this solution. Good job all!
EDIT:
I created a blog post to detail the steps and provide additional information:
http://www.solutionmaniacs.com/blog/2012/5/29/qtp-calling-c-dll-in-vbscript.html
Как сказал Марк, но я думаю, что это заслуживает ответа. Если вы гарантируете, что ваша dll будет доступна через механизм COM, ваш сценарий должен иметь возможность вызывать ее с помощью таких вещей, как CreateObject .
Ваша функция статична. Члены статического класса не могут быть сопоставлены с членами интерфейса, и если он не может реализовать интерфейс .NET, он определенно не будет реализовывать интерфейс COM.