VB to C # translation

In VB(ASP.NET)

Application("myapp")= Server.CreateObject("APP.Engine ")

aa = Application("myapp").myMethod(2)

works.

I tried it in C#

Application["myapp"]= Server.CreateObject("APP.Engine")

but

Application[" myapp"].myMethod(2)

Failed

'object' does not contain a definition for'myMethod'

How to expose public interface in C#?

If you have access to the defined type (that is, not the original COM object), you can simply convert:

((APP.Engine)Application["myapp"]).myMethod(2);

If you are using c# 4.0, you can perform the following operations:

dymamic myApp = Application["myapp"];
myApp.myMethod(2);

Otherwise, you will have to use reflection and Type.InvokeMember(…) to use dynamic method invocation

In VB(ASP.NET)

Application("myapp")= Server.CreateObject("APP.Engine")

aa = Application("myapp").myMethod(2)

works.

I tried it in C#

Application["myapp"]= Server.CreateObject("APP.Engine")

pre>

But

Application["myapp"].myMethod(2)

Failed

'object' does not contain a definition for'myMethod'

How to expose public interface in C#?

If you have access to the defined type (that is, not the original COM object), you can simply convert:

((APP.Engine)Application["myapp"]).myMethod(2);

If you are using c#4.0, you can do the following:

dymamic myApp = Application["myapp"];
myApp.myMethod(2);

Otherwise, you will have to use reflection and Type.InvokeMember (...)Use dynamic method call

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3425 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.