Please give VB.Net some equivalent for C# 'dynamic' with Option Strict On - by MarkTJackson

Status : 

  Other<br /><br />
		This item had a custom resolution.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 591963 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 8/31/2010 8:13:26 AM
Access Restriction Public


Please give VB.Net an equivalent for the C# 4 'dynamic' keyword when using Option Strict On. 

In my experience most professional developers prefer to avoid Option Strict Off. In C#, with the dynamic keyword we can be very explicit about the dynamic parts of my program. It's like telling the compiler: "hey, I know what I'm doing for this specific part of my program". With VB.Net we have to turn off Option Strict for a whole module, which can lead to subtle bugs creeping in. 

Please can we have some equivalent to 'dynamic' so that we can use some of the more modern techniques in a safe way? Like using a dynamic object to reference the HTML Document Object Model (DOM), or accessing a dynamic language like IronPython.
Sign in to post a comment.
Posted by Đonny on 1/6/2011 at 1:54 PM
I'd personally prefer the Dynamic pseudo-type (as in C#, two ways of late binding), but #pragma is acceptable for me (if it can be used inside a method, not like #regions in VB, like #regions in C#).
Posted by Lucian [MSFT] on 1/5/2011 at 8:57 AM
Hi Mark. Thanks for the comment. I agree that many developers don't like to use "Option Strict Off". And accessing DOM is a really good example.

One approach is not to have any "Option Strict" declaration at the top of the file. Instead right click on the project > Properties > Compile and set them to "warning". This way you're still explicit about where it's happening -- except the explicitness comes through as warnings rather than through annotations in your code. But that's not a very good workaround.

We discussed this in VB Language Design Meetings but didn't come up with very good answers. Here are the notes:

The main thing is that we're reluctant to have two ways to do late-binding in the language. I think that localized #pragmas would proably be the best solution.

I've added your connect bug number to our internal "backlog list of items that users have requested". We'll use the weight of requests in this list to help guide our plans for future versions.

Thanks again for the feedback,

Lucian Wischik, VB spec lead
Posted by Microsoft on 8/31/2010 at 5:04 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(