.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

More Versioning Fun With Optional Arguments

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
In my last blog post , I covered some challenges with versioning methods that differ only by optional parameters. If you haven't read it, go read it. If I do say so myself, it's kind of interesting. ;) In this post, I want to cover another very subtle versioning issue with using optional parameters. At the very end of that last post, I made the following comment. By the way, you can add overloads that have additional required parameters. So in this way, you are in the same boat as before. However, this can lead to subtle bugs. Let's walk through a scenario. Imagine that some class library has the following method in version 1.0. public static void Foo( string s1, string s2, string s3 = "v1" ) { Console.WriteLine( "version 1"...(read more)

View Complete Post

More Related Resource Links

Versioning Issues With Optional Arguments

One nice new feature introduced in C# 4 is support for named and optional arguments . While these two features are often discussed together, they really are orthogonal concepts. Let's look at a quick example of these two concepts at work. Suppose we have a class with one method having the following signature. // v1 public static void Redirect( string url, string protocol = "http" ); This hypothetical library contains a single method that takes in two parameters, a required string url and an optional string protocol . The following shows the six possible ways this method can be called. HttpHelpers.Redirect( "http://haacked.com/" ); HttpHelpers.Redirect(url: "http://haacked.com/" ); HttpHelpers.Redirect( "http...(read more)

Foundations: Versioning Workflows


Developers often struggle with versioning workflows and their related classes. Matt Milner discusses the core issues related to workflow versioning and provides recommendations for making changes to workflow definitions, activities, and workflow services.

Matthew Milner

MSDN Magazine May 2009

.NET Zero Deployment: Security and Versioning Models in the Windows Forms Engine Help You Create and


Windows Forms applications solve many of the problems inherent in building Web applications the old fashioned way?with HTML. To demonstrate the use of Windows Forms over the Web, the author takes his existing app, Wahoo!, and ports it to Windows Forms. In doing so, he discusses versioning, linked files, security, storage isolation, the deployment model, and everything else you need to get started building your own Windows Forms apps for the Web.

Chris Sells

MSDN Magazine July 2002

How to Post Code To Your Blog and other Religious Arguments

If you've got a programming blog, chances are you'll want to post some code snippets. Posting code sounds easy but it's surprisingly tricky if you consider all the ways that people will be reading your blog. There's a number of ways. Here's a few and their pros and cons . Copy Paste from your IDE (like Visual Studio, for example) If I copy paste directly from VS into my editor of choice, Windows Live Writer, I'll get a <pre> section. using System; namespace WindowsGame1 { #if WINDOWS || XBOX     static class Program     {         /// <summary>         /// The main entry point for the application.        ...(read more)

Optional named parameters work pretty well

Rob has found a use for dynamic: http://blog.wekeroad.com/2010/08/06/flexible-parameters-with-csharp Yay! Let's celebrate! Well, I was a little puzzled because I don't think it quite adds up in the specific example he chose (although please see no aggressiveness here: Rob's a friend; peace!). The idea is to have the same flexibility that a dynamic language can offer in terms of evolution of an API. Here's his original Ruby example: def my_method(args)   thing_one = args["thing1"]   thing_two = args["thing2"] end my_method :thing1 => "value", :thing2 = Time.now The idea, which is quite common in dynamic languages, is that instead of passing a list of predetermined parameters in a specific order, you...(read more)

Web Part Versioning and Deployment (properties only)


Suppose I have a 3<sup>rd</sup> party Web Part (source code provided, with Web Part deployed as a Feature) that’s installed and used in several Sites within a Site Collection.  I want to make changes not to the source code (which would require updating the assembly and deploying the changes as an updated Feature/Solution Package), but to property values of the Web Part that exist.  Say the WP exists on 10 pages, and I want to change the WP’s Title property from “Amazing Vendor Web Part” to “My New Title”.


First, would this be considered an “out-of-band” patch?  Not that it matters terribly how to label this…


Second, would the ideal approach be to simply add code within a Feature Receiver in that Web Parts VS project (the Feat

If you have SharePoint Document Versioning Enabled, do you also use the retention settings?

I am looking for stats on how many environments are out there using document versioning in there libraries but are perhaps not selecting the retention settings. (e.g. "Optionally limit the number of versions to retain" section) This as we all know in SharePoint is a major cause of database growth.
Tony Parker, MSCE . MCTP. MCITP "Anything worth doing, is worth doing right"

Process.Start - arguments length restriction to 2080 characters

Hi, I'm wondering why is there a limit to "The sum of the length of the arguments and the length of the full path to the process " to 2080? I see that the documentation says that a Win32Exception is thrown if this exceeds 2080 characters. Can someone please explain to me this limit? I'm trying to start a process and I have a lot of arguments to pass, and of course ... I exceed the limit of 2080.   Thanks, Ionut.

Microsoft.mshtml / mshtml.dll versioning and reference issues

Hi, Couldn't find a more relevant section to put this in, so I'll throw it here as I'm coding in C#, although that doesn't really matter. I'm using .NET 4, trying to add a reference to mshtml, and I want to have all the capabilities depending on the version the client has installed. If I add a reference to the COM component called 'Microsoft HTML Object Library', the reference is labelled "MSHTML" and the path points to an assembly in the GAC called 'Microsoft.html' for some reason. Even though I have IE8 installed, it is still missing the IE8 interfaces, which makes me think it is just pointing to the Microsoft.html.dll wrapper instead of generating the reference from the actual COM compoment. The Microsoft.html.dll wrapper is missing the IE8 interfaces, and from what I can tell, this wrapper is somewhat unnecessary with the .NET 4 "Embed Interop Types" feature. The other thing that scares me is the "Specific Version" field on the reference, which is set to true, and I can't change it. What if someone has a lower version of "Microsoft HTML Object Library" than my dev machine? EDIT: Sorry, got a little confused between adding a reference to Microsoft.mshtml .NET assembly and directly to the COM component.  If I add the reference to the COM component, "Specific Version" isn't available in the properties, bu

Optional Parameters - Not taking values when supplied

All, I have a report that takes 2 optional parameters, one int and one datetime. My data tab is set up as follows: CommandType = Text, Parameters has Parameters.Value etc. for both. Report Parameters are allowed NULL value, Default Value is NULL, datatypes are Integer and Datetime as well. This only runs when the parameters are not supplied values, when I enter a date, it does not take it into account, same for the int value. I have run the proc manually to verify that the query is set up correctly, it seems like the values are not being passed? Any help debugging this would be helpful. Thanks.

optional output parameter in CLR Stored Procedure

I'm trying to transpose a Procedure that sends mail via CDO.Message and Ole Automation to a .Net CLR Procedure. this procedure must have the same parameters in the same order as the original to maintain compatibility with everything that already uses it. the declaration goes as follow   <Microsoft.SqlServer.Server.SqlProcedure(name:="SP_ENVIAEMAIL")> _<br/> Public Shared Sub ENVIAEMAIL(<SqlFacet(MaxSize:=100)> Optional ByVal De As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Para As String = "", _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Copia As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Oculta As String = "", _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Assunto As String = "", <SqlFacet(MaxSize:=-1)> Optional ByVal Mensagem As String = "", _<br/> <SqlFacet(MaxSize:=-1)> Optional ByVal Anexo As String = "", _<br/> <strong><SqlFacet(MaxSize:=1000)> <Out()> Optional ByVal Retorno As String = ""</strong> , _<br/> <SqlFacet(MaxSize:=100)> Optional ByVal Smtp As String = "", <SqlFacet(MaxSize:=100)> Optional ByVal Usuario As String = "",

The best overloaded method match for... has some invalid arguments

I have a compilation error generated by this scenario: i have : 1. DataAccessLayses 2. Entity 3. PresentationLayer(web application)4. BankServices(web service) inside the webservice i have one web method with argument of my pre-defined class library it name is CustomerEL and the class in PresentationLayer calling the webservice method ,CustomerEL cusE = new CustomerEL();objsv.addCustomer(cusE);(addCustomer(<argument>) is method in BankServices)  and here the eror occuredcan you help me !Regards

Enumerating Variables & Arguments in Rehosted Designer

I'm trying to enumerate the variables and arguments of a workflow after I load it into my rehosted designer.  I see that I can use ActivityMetadata.GetArgumentsWithReflection() and ActivityMetadata.GetVariablesWithReflection() but those require that I have ActivityMetadata to start with.  So the real question is, how do I get the ActivityMetadata once I've done MyWorkflowDesigner.Load(XamlPath);?Thanks in advance.ChuckChuck Berg | Consulting Engineer | Corporate IT - Station Casinos, Inc.

Document Versioning

Is there a way to customise the version numbers to depict what department they belong to, such as Engineering will be eng1, eng2, eng3 etc and Logistics could be log1, log2, log3 etc?

How to persist workflow with non-serializable arguments

I have a workflow that has some arguments for underlying components (DAL implementation, email sender etc). It also has a  WCF data contract and other serializable arguments. I need to persist and unload this workflow and then resume later on. It is throwing an exception because it is trying to serialize and persist all the workflow arguments. Is there a way to get the serializer to persist only those arguments that can be serialized?

Subversion and SSIS package versioning ...

I see some posts recommending MS's change control system. We use Subversion and I was wondering if people have any thoughts or ideas on what is the correct way of maintaining SSIS packages in Subversion. Any thoughts or ideas are greatly appreciated.   Thanks  Jagannathan Santhanam

Silverlight 4.0 Optional & Named Parameters

Named & optional parameters are a new C# language feature coming up with .NET FX 4.0 and guess what. it's in Silverlight 4 as well! Optional parameters will come very useful when defining complex APIs where you would usually have to provide several overloads for the same method for it to make sense to wide variety of usages. Let's take a look at this basic example:public void PositionWindow(bool isTopMost, double left = 0, double top = 0, double width = 800, double height = 600){Window window = Application.Current.MainWindow; window.TopMost = isTopMost;window.Left = left; window.Top = top;window.Width = width;window.Height = height;} isTopMost is the only parameter that's required, all other parameter specify their default value, which makes them optional. But what if you wanted to provide the size only and leave the position to be set to defaults? Enter named parameters. The same method above can be called also with:PositionWindow(isTopMost:true, width: 600, height: 200); // named parametersPositionWindow(true, width: 600, height: 200); // naming is optional when positioned rightPositionWindow(true, height: 200, width: 600); // order doesn't matterPositionWindow(height: 200, width: 600, isTopMost: true); // ... even with the required parameters Simple ... Cheers:)
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend