Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:33:03+00:00 2026-05-18T08:33:03+00:00

I am having more problems with my converting of vb.net to c#.net. I have

  • 0

I am having more problems with my converting of vb.net to c#.net.

I have some files in vb.net that have “Option Strict Off” to allow for bad programming. When I convert to c# I use “dynamic” until I come back and fix problems, and this works in all cases

But now I have this code:

Public Class ContractResults
   'Big class definition
   Public Shared Sub CleanCache()
       'Code here
   End Sub
End Class

And in a file with Option Strict Off:

Public Sub VerifyResults(result as Object)
   'Here, result is normally ContractResults
   'first it check for that then call this:
   result.CleanCache()
End Sub

In c# I use “dynamic”, but a runtime error pops up when I call “static” method with dynamic reference. In vb.net, I can called “shared” sub from instance, but in c# this is not allowed

Exception:
“Microsoft.CSharp.RuntimeBinder.RuntimeBinderException”
“Member ‘ContractTypes.ContractResults.CleanCache()’ cannot be accessed with an instance reference; qualify it with a type name instead”

It seems I must convert code to use actual type, but then this means much rewriting of more parts. Is anyone able to show another way?

I want to make sure you do not think I can use

(result as ContractResults).CleanCache();

Because all types that may be passed in have “CleanCache()” method, but do not inherits from anything the same other than “Object”. There are many types (30!) that have this “static” method and so that is why it uses Option Strict Off

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:33:03+00:00Added an answer on May 18, 2026 at 8:33 am

    You could use reflection:

    result.GetType().InvokeMember("CleanCache", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy, null, null, new object[0]);
    

    (untested)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am unfortunately having some more problems with JQuery of late. I am working
I'm having problems with stored procedures, this part to me more specific : CREATE
What is more efficient -- having a IDbTransaction in the .net code or handling
I'm having some problems connecting to a SOAP Service at https://test.salesforce.com . I use
I'm having some problems with iText . (Specifically, iTextSharp.) I'm trying to split a
I have an old .net 1.0 webapp that needs a bit of maintenance done
new to python and I'm having trouble converting a script to a more effective
I'm having so many problems getting more than 1 MVC project up and running
I encountered a problem after having more than one texture in my engine. My
I am currently having a problem with a UITableView, and more precisely with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.