Search Results

Search found 8839 results on 354 pages for 'optional parameters'.

Page 1/354 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C# 4: conflicting overloaded methods with optional parameters

    - by Thomas
    I have two overloaded methods, one with an optional parameter. void foo(string a) { } void foo(string a, int b = 0) { } now I call: foo("abc"); interestingly the first overload is called. why not the second overload with optional value set to zero? To be honest, I would have expect the compiler to bring an error, at least a warning to avoid unintentional execution of the wrong method. What's the reason for this behaviour? Why did the C# team define it that way? Thanks for your opinions!

    Read the article

  • Google webmaster tools: parameters that only apply on one page

    - by Imagine digital
    I'm trying to get my e-commerce website on google and still figuring out how it all works. Now, I have seen this feature named URL-parameters, allowing me to set different parameters that affect page content to be indexed (one can also set parameters that do not affect the page, but for me that does not apply..). The question I have about this is whether and how I should add parameters that I only have on some pages of my site. example: The homepage of my site is www.mysite.nl. no parameters at all. But when a user clicks the navigation bar, it links to www.mysite.nl/itemList.php?category=&....subCategory=.... The parameters category and subCategory define whether there is content on my itemList page and what content that is. It gets matching products out of my database based on those 2 variables. The question: How do I make sure that I apply the google URL Parameters function decently for my website?

    Read the article

  • Patterns for simulating optional "out" parameters in C#?

    - by Jesse McGrew
    I'm translating an API from C to C#, and one of the functions allocates a number of related objects, some of which are optional. The C version accepts several pointer parameters which are used to return integer handles to the objects, and the caller can pass NULL for some of the pointers to avoid allocating those objects: void initialize(int *mainObjPtr, int *subObjPtr, int *anotherSubObjPtr); initialize(&mainObj, &subObj, NULL); For the C# version, the obvious translation would use out parameters instead of pointers: public static void Initialize(out int mainObj, out int subObj, out int anotherSubObj); ... but this leaves no way to indicate which objects are unwanted. Are there any well-known examples of C# APIs doing something similar that I could imitate? If not, any suggestions?

    Read the article

  • Overload Resolution and Optional Arguments in C# 4

    - by Dale McCoy
    I am working with some code that has seven overloads of a function TraceWrite: void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, bool LogToFileOnly, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, string PieceID, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, LogWindowCommandENUM LogWindowCommand, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, bool UserMessage, int UserMessagePercent, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, string PieceID, LogWindowCommandENUM LogWindowCommand, string Data = ""); void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, LogWindowCommandENUM LogWindowCommand, bool UserMessage, int UserMessagePercent, string Data = ""); (All public static, namespacing noise elided above and throughout.) So, with that background: 1) Elsewhere, I call TraceWrite with four arguments: string, LogLevelENUM, string, bool, and I get the following errors: error CS1502: The best overloaded method match for 'TraceWrite(string, LogLevelENUM, string, string)' has some invalid arguments error CS1503: Argument '4': cannot convert from 'bool' to 'string' Why doesn't this call resolve to the second overload? (TraceWrite(string, LogLevelENUM, string, bool, string = "")) 2) If I were to call TraceWrite with string, LogLevelENUM, string, string, which overload would be called? The first or the third? And why?

    Read the article

  • SQL optional parameters through VB.net

    - by ScaryJones
    I've a document search page with three listboxes that allow multiple selections. They're: Category A Year Category B Only category A is mandatory, the others are optional parameters and might be empty. Each document can belong to multiple options in Category A and multiple options Category B but each document only has one year associated with it. I've kind of got this working through building up a dynamic SQL string but it's messy and I hate using it so I thought I'd ask here if anyone could see an easier way of doing this. An example of the kind of dynamic SQL query i end up with follows: select * from library where libraryID in (select distinct libraryID from categoryAdocs where categoryAdocID in (4)) or year in (2004)

    Read the article

  • Application pool crashing regularly (8007006d) (Service Unavailable)

    - by Phil
    I have a basic web form site running. Nothing out of the ordinary. It is frequently crashing the application pool. The error code I got from the logs is '8007006d'. Googling this does not come up with the usual bevy of results.... I do get a few people with a similar problem. Any the advise seems to be that the error is related to registry permissions. Can anyone confirm / disconfirm this theory. That if I get error 8007006d it is definately a reg permissions problem? Here is the code from my page. I'm not seeing anything that would cause a memory leak or make this happen. It is basically just one big insert command with many parameters? Imports System.Web.Configuration Imports System.Data.SqlClient Imports System.Net.Mail Imports System.IO Imports System.Globalization Partial Class _Default Inherits System.Web.UI.Page Public Sub WriteError(ByVal errorMessage As String) Try Dim path As String = "~/Error/" & DateTime.Today.ToString("dd-mm-yy") & ".txt" If (Not File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) Then File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close() End If Using w As StreamWriter = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path)) w.WriteLine(Constants.vbCrLf & "Log Entry : ") w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture)) Dim err As String = "Error in: " & System.Web.HttpContext.Current.Request.Url.ToString() & ". Error Message:" & errorMessage w.WriteLine(err) w.WriteLine("__________________________") w.Flush() w.Close() End Using Catch ex As Exception WriteError(ex.Message) End Try End Sub Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad otherlanguagespecify.Text = "Language: Speaking: Reading: Writing:" 'Show / hide 'other' panels ProvincePanel.Visible = False If Province.SelectedValue = "Other" Then ProvincePanel.Visible = True End If languagespanel.Visible = False If OtherLanguage.Checked Then languagespanel.Visible = True End If End Sub Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click Dim areasexpertise As String = String.Empty Dim areasli As ListItem Dim english As String = String.Empty Dim connstring As String = WebConfigurationManager.ConnectionStrings("Str").ToString() Dim c As SqlConnection = New SqlConnection(connstring) Dim s As String = ("INSERT INTO [MBA_EOI]") & _ ("([subdate],[surname], [name], [dob], [nationality], [postaladdress],") & _ ("[province],[city], [postcode], [worktelephone],") & _ ("[hometelephone], [mobile], [email],[fax], [institution1],") & _ ("[institution2], [institution3], [institution4], [institutiondate1], [institutiondate2],") & _ ("[institutiondate3], [institutiondate4],[institutionquals1], [institutionquals2], [institutionquals3],") & _ ("[institutionquals4],[profdates1], [profdates2],") & _ ("[profdates3], [profdates4], [profdates5], [profdates6], [profdates7], ") & _ ("[profloc1], [profloc2], [profloc3], [profloc4], [profloc5],") & _ ("[profloc6], [profloc7], [profcomp1], [profcomp2], [profcomp3],") & _ ("[profcomp4], [profcomp5], [profcomp6], [profcomp7], [profpos1],") & _ ("[profpos2], [profpos3], [profpos4], [profpos5], [profpos6],") & _ ("[profpos7], [profdesc1], [profdesc2], [profdesc3], [profdesc4],") & _ ("[profdesc5],[profdesc6],[profdesc7], [company1], [company2],") & _ ("[company3], [company4], [company5], [nature1], [nature2],") & _ ("[nature3], [nature4], [nature5], [workdate1], [workdate2],") & _ ("[workdate3], [workdate4], [workdate5], [contactname1], [contactname2],") & _ ("[contactname3], [contactname4], [contactname5], [wtelephone1], [wtelephone2],") & _ ("[wtelephone3],[wtelephone4], [wtelephone5], [philosophy], [publications],") & _ ("[english], [otherlanguage], [areasofexpertise], [otherareasofexpertise],") & _ ("[assessortrue], [coordinatortrue], [facilitatortrue], [moderatortrue], [productdevelopertrue],") & _ ("[projectmanagertrue], [assessorexp], [coordinatorexp], [facilitatorexp], [moderatorexp],") & _ ("[productdeveloperexp], [projectmanagerexp], [assessorlvl], [coordinatorlvl], [facilitatorlvl],") & _ ("[moderatorlvl], [productdeveloperlvl], [projectmanagerlvl], [assessorpref], [coordinatorpref],") & _ ("[FacilitatorPref], [ModeratorPref], [ProductDeveloperPref], [ProjectManagerPref], [designation], [professortrue],") & _ ("[professorlvl], [professorexp], [professorpref], [lecturertrue], [lecturerpref], [lecturerlvl], [lecturerexp], [affiliations], [educationmore], ") & _ ("[wemail1], [wemail2], [wemail3], [wemail4], [wemail5])") & _ ("VALUES") & _ ("(@subdate, @surname, @name, @dob, @nationality, @postaladdress,") & _ ("@province,@city, @postcode, @worktelephone,") & _ ("@hometelephone, @mobile, @email, @fax, @inst1,") & _ ("@inst2, @inst3, @inst4, @instdate1, @instdate2,") & _ ("@instdate3, @instdate4, @instquals1, @instquals2, @instquals3,") & _ ("@instquals4, @profdates1, @profdates2,") & _ ("@profdates3, @profdates4, @profdates5, @profdates6, @profdates7,") & _ ("@profloc1, @profloc2, @profloc3, @profloc4, @profloc5,") & _ ("@profloc6, @profloc7, @profcomp1, @profcomp2, @profcomp3,") & _ ("@profcomp4, @profcomp5, @profcomp6, @profcomp7, @profpos1,") & _ ("@profpos1, @profpos1, @profpos4, @profpos5, @profpos6,") & _ ("@profpos7, @profdesc1, @profdesc2, @profdesc3, @profdesc4,") & _ ("@profdesc5, @profdesc6, @profdesc7, @company1, @company2,") & _ ("@company3, @company4, @company5,@nature1, @nature2,") & _ ("@nature3, @nature4, @nature5, @workdate1, @workdate2,") & _ ("@workdate3, @workdate4, @workdate5, @contactname1, @contactname2,") & _ ("@contactname3, @contactname4, @contactname5, @wtelephone1, @wtelephone2,") & _ ("@wtelephone3,@wtelephone4, @wtelephone5, @philosophy, @publications,") & _ ("@english, @otherlanguage, @areasofexpertise, @otherareasofexpertise,") & _ ("@assessor, @coordinator, @facilitator, @moderator, @productdeveloper,") & _ ("@projectmanager, @assessorexp, @coordinatorexp, @facilitatorexp, @moderatorexp,") & _ ("@productdeveloperexp, @projectmanagerexp, @assessorlvl, @coordinatorlvl, @facilitatorlvl,") & _ ("@moderatorlvl, @productdeveloperlvl, @projectmanagerlvl, @assessorpref, @coordinatorpref,") & _ ("@facilitatorpref, @moderatorpref, @productdeveloperpref, @projectmanagerpref, @designation, @professor, @professorlvl, @professorexp, @professorpref,") & _ ("@lecturer, @lecturerpref, @lecturerlvl, @lecturerexp, @affiliations, @educationmore, ") & _ ("@wemail1, @wemail2, @wemail3, @wemail4, @wemail5)") 'Setup birthday Dim birthdaystring As String = MonthBirth.SelectedValue.ToString & "/" & DayBirth.SelectedValue.ToString & "/" & YearBirth.SelectedValue.ToString Dim birthday As DateTime = Convert.ToDateTime(birthdaystring) Try Dim x As New SqlCommand(s, c) x.Parameters.AddWithValue("@subdate", DateTime.Now()) x.Parameters.AddWithValue("@surname", Surname.Text) x.Parameters.AddWithValue("@name", Name.Text) x.Parameters.AddWithValue("@dob", birthday) x.Parameters.AddWithValue("@nationality", Nationality.Text) x.Parameters.AddWithValue("@postaladdress", Postaladdress.Text) x.Parameters.AddWithValue("@designation", Designation.SelectedItem.ToString) 'to control whether or not 'other' province is selected If Province.SelectedValue = "Other" Then x.Parameters.AddWithValue("@province", Otherprovince.Text) Else x.Parameters.AddWithValue("@province", Province.SelectedValue.ToString) End If x.Parameters.AddWithValue("@city", City.Text) x.Parameters.AddWithValue("@postcode", Postcode.Text) x.Parameters.AddWithValue("@worktelephone", Worktelephone.Text) x.Parameters.AddWithValue("@hometelephone", Hometelephone.Text) x.Parameters.AddWithValue("@mobile", Mobile.Text) x.Parameters.AddWithValue("@email", Email.Text) x.Parameters.AddWithValue("@fax", Fax.Text) 'Add education params to x command x.Parameters.AddWithValue("@inst1", Institution1.Text) x.Parameters.AddWithValue("@inst2", Institution2.Text) x.Parameters.AddWithValue("@inst3", Institution3.Text) x.Parameters.AddWithValue("@inst4", Institution4.Text) x.Parameters.AddWithValue("@instdate1", Institutiondates1.Text) x.Parameters.AddWithValue("@instdate2", Institutiondates2.Text) x.Parameters.AddWithValue("@instdate3", Institutiondates3.Text) x.Parameters.AddWithValue("@instdate4", Institutiondates4.Text) x.Parameters.AddWithValue("@instquals1", Institution1quals.Text) x.Parameters.AddWithValue("@instquals2", Institution2quals.Text) x.Parameters.AddWithValue("@instquals3", Institution3quals.Text) x.Parameters.AddWithValue("@instquals4", Institution4quals.Text) 'Add checkbox params to x command Dim eli As ListItem For Each eli In EnglishSkills.Items If eli.Selected Then english += eli.Text + " | " End If Next x.Parameters.AddWithValue("@english", english) For Each areasli In Expertiselist.Items If areasli.Selected Then areasexpertise += " ; " & areasli.Text End If Next x.Parameters.AddWithValue("@areasofexpertise", areasexpertise) If OtherLanguage.Checked.ToString Then x.Parameters.AddWithValue("@otherlanguage", otherlanguagespecify.Text) Else x.Parameters.AddWithValue("@otherlanguage", DBNull.Value) End If 'Add competencies params to x command x.Parameters.AddWithValue("@assessor", AssessorTrue.Checked) x.Parameters.AddWithValue("@coordinator", CoordinatorTrue.Checked) x.Parameters.AddWithValue("@facilitator", FacilitatorTrue.Checked) x.Parameters.AddWithValue("@moderator", ModeratorTrue.Checked) x.Parameters.AddWithValue("@productdeveloper", ProductDeveloperTrue.Checked) x.Parameters.AddWithValue("@projectmanager", ProjectManagerTrue.Checked) x.Parameters.AddWithValue("@assessorexp", Assessorexp.Text) x.Parameters.AddWithValue("@coordinatorexp", coordinatorexp.Text) x.Parameters.AddWithValue("@facilitatorexp", facilitatorexp.Text) x.Parameters.AddWithValue("@moderatorexp", moderatorexp.Text) x.Parameters.AddWithValue("@productdeveloperexp", productdeveloperexp.Text) x.Parameters.AddWithValue("@projectmanagerexp", projectmanagerexp.Text) x.Parameters.AddWithValue("@assessorlvl", Assessorlevel.Text) x.Parameters.AddWithValue("@coordinatorlvl", Coordinatorlevel.Text) x.Parameters.AddWithValue("@facilitatorlvl", Facilitatorlevel.Text) x.Parameters.AddWithValue("@moderatorlvl", Moderatorlevel.Text) x.Parameters.AddWithValue("@productdeveloperlvl", Productdeveloperlevel.Text) x.Parameters.AddWithValue("@projectmanagerlvl", Projectmanagerlevel.Text) x.Parameters.AddWithValue("@assessorpref", AssessorPref.Text) x.Parameters.AddWithValue("@coordinatorpref", CoordinatorPref.Checked) x.Parameters.AddWithValue("@facilitatorpref", FacilitatorPref.Checked) x.Parameters.AddWithValue("@moderatorpref", ModeratorPref.Checked) x.Parameters.AddWithValue("@productdeveloperpref", ProductDeveloperPref.Checked) x.Parameters.AddWithValue("@projectmanagerpref", ProjectManagerPref.Checked) x.Parameters.AddWithValue("@professorpref", ProfessorPref.Checked) x.Parameters.AddWithValue("@professorlvl", Professorlevel.Text) x.Parameters.AddWithValue("@professor", ProfessorTrue.Checked) x.Parameters.AddWithValue("@professorexp", professorexp.Text) x.Parameters.AddWithValue("@lecturerpref", LecturerPref.Checked) x.Parameters.AddWithValue("@lecturerlvl", Lecturerlevel.Text) x.Parameters.AddWithValue("@lecturer", LecturerTrue.Checked) x.Parameters.AddWithValue("@lecturerexp", lecturerexp.Text) 'Add professional experience params to x command x.Parameters.AddWithValue("@profdates1", ProfDates1.Text) x.Parameters.AddWithValue("@profdates2", ProfDates2.Text) x.Parameters.AddWithValue("@profdates3", ProfDates3.Text) x.Parameters.AddWithValue("@profdates4", ProfDates4.Text) x.Parameters.AddWithValue("@profdates5", ProfDates5.Text) x.Parameters.AddWithValue("@profdates6", ProfDates6.Text) x.Parameters.AddWithValue("@profdates7", ProfDates7.Text) x.Parameters.AddWithValue("@profloc1", ProfDates1.Text) x.Parameters.AddWithValue("@profloc2", ProfDates2.Text) x.Parameters.AddWithValue("@profloc3", ProfDates3.Text) x.Parameters.AddWithValue("@profloc4", ProfDates4.Text) x.Parameters.AddWithValue("@profloc5", ProfDates5.Text) x.Parameters.AddWithValue("@profloc6", ProfDates6.Text) x.Parameters.AddWithValue("@profloc7", ProfDates7.Text) x.Parameters.AddWithValue("@profcomp1", ProfCompany1.Text) x.Parameters.AddWithValue("@profcomp2", ProfCompany2.Text) x.Parameters.AddWithValue("@profcomp3", ProfCompany3.Text) x.Parameters.AddWithValue("@profcomp4", ProfCompany4.Text) x.Parameters.AddWithValue("@profcomp5", ProfCompany5.Text) x.Parameters.AddWithValue("@profcomp6", ProfCompany6.Text) x.Parameters.AddWithValue("@profcomp7", ProfCompany7.Text) x.Parameters.AddWithValue("@profpos1", Profpos1.Text) x.Parameters.AddWithValue("@profpos2", Profpos2.Text) x.Parameters.AddWithValue("@profpos3", Profpos3.Text) x.Parameters.AddWithValue("@profpos4", Profpos4.Text) x.Parameters.AddWithValue("@profpos5", Profpos5.Text) x.Parameters.AddWithValue("@profpos6", Profpos6.Text) x.Parameters.AddWithValue("@profpos7", Profpos7.Text) x.Parameters.AddWithValue("@profdesc1", ProfDesc1.Text) x.Parameters.AddWithValue("@profdesc2", ProfDesc2.Text) x.Parameters.AddWithValue("@profdesc3", ProfDesc2.Text) x.Parameters.AddWithValue("@profdesc4", ProfDesc4.Text) x.Parameters.AddWithValue("@profdesc5", ProfDesc5.Text) x.Parameters.AddWithValue("@profdesc6", ProfDesc6.Text) x.Parameters.AddWithValue("@profdesc7", ProfDesc7.Text) 'Add references parameters to x command x.Parameters.AddWithValue("@company1", company1.Text) x.Parameters.AddWithValue("@company2", company2.Text) x.Parameters.AddWithValue("@company3", company3.Text) x.Parameters.AddWithValue("@company4", company4.Text) x.Parameters.AddWithValue("@company5", company5.Text) x.Parameters.AddWithValue("@nature1", natureofwork1.Text) x.Parameters.AddWithValue("@nature2", natureofwork2.Text) x.Parameters.AddWithValue("@nature3", natureofwork3.Text) x.Parameters.AddWithValue("@nature4", natureofwork4.Text) x.Parameters.AddWithValue("@nature5", natureofwork5.Text) x.Parameters.AddWithValue("@workdate1", workdate1.Text) x.Parameters.AddWithValue("@workdate2", workdate2.Text) x.Parameters.AddWithValue("@workdate3", workdate3.Text) x.Parameters.AddWithValue("@workdate4", workdate4.Text) x.Parameters.AddWithValue("@workdate5", workdate5.Text) x.Parameters.AddWithValue("@contactname1", ContactName1.Text) x.Parameters.AddWithValue("@contactname2", ContactName2.Text) x.Parameters.AddWithValue("@contactname3", ContactName3.Text) x.Parameters.AddWithValue("@contactname4", ContactName4.Text) x.Parameters.AddWithValue("@contactname5", ContactName5.Text) x.Parameters.AddWithValue("@wtelephone1", Telephone1.Text) x.Parameters.AddWithValue("@wtelephone2", Telephone2.Text) x.Parameters.AddWithValue("@wtelephone3", Telephone3.Text) x.Parameters.AddWithValue("@wtelephone4", Telephone4.Text) x.Parameters.AddWithValue("@wtelephone5", Telephone5.Text) x.Parameters.AddWithValue("@wemail1", Email1.Text) x.Parameters.AddWithValue("@wemail2", Email2.Text) x.Parameters.AddWithValue("@wemail3", Email3.Text) x.Parameters.AddWithValue("@wemail4", Email4.Text) x.Parameters.AddWithValue("@wemail5", Email5.Text) 'Add other areas of expertise parameter x.Parameters.AddWithValue("@otherareasofexpertise", Otherareasofexpertise.Text) 'Add philosophy / pubs / affils comands to x command x.Parameters.AddWithValue("@philosophy", learningphilosophy.Text) x.Parameters.AddWithValue("@publications", publicationdetails.Text) x.Parameters.AddWithValue("@affiliations", affiliations.Text) x.Parameters.AddWithValue("@educationmore", educationmore.Text) c.Open() x.ExecuteNonQuery() c.Close() Catch ex As Exception WriteError(ex.ToString) End Try 'If everyone is happy, redirect to thank you page If (Page.IsValid) Then Response.Redirect("Thanks.aspx") End If End Sub End Class

    Read the article

  • De-index URL parameters by value

    - by Doug Firr
    Upon reading over this question is lengthy so allow me to provide a one sentence summary: I need to get Google to de-index URLs that have parameters with certain values appended I have a website example.com with language translations. There used to be many translations but I deleted them all so that only English (Default) and French options remain. When one selects a language option a parameter is aded to the URL. For example, the home page: https://example.com (default) https://example.com/main?l=fr_FR (French) I added a robots.txt to stop Google from crawling any of the language translations: # robots.txt generated at http://www.mcanerin.com User-agent: * Disallow: Disallow: /cgi-bin/ Disallow: /*?l= So any pages containing "?l=" should not be crawled. I checked in GWT using the robots testing tool. It works. But under html improvements the previously crawled language translation URLs remain indexed. The internet says to add a 404 to the header of the removed URLs so the Googles knows to de-index it. I checked to see what my CMS would throw up if I visited one of the URLs that should no longer exist. This URL was listed in GWT under duplicate title tags (One of the reasons I want to scrub up my URLS) https://example.com/reports/view/884?l=vi_VN&l=hy_AM This URL should not exist - I removed the language translations. The page loads when it should not! I played around. I typed example.com?whatever123 It seems that parameters always load as long as everything before the question mark is a real URL. So if Google has indexed all these URLS with parameters how do I remove them? I cannot check if a 404 is being generated because the page always loads because it's a parameter that needs to be de-indexed.

    Read the article

  • Required Parameters [SSIS Denali]

    - by jamiet
    SQL Server Integration Services (SSIS) in its 2005 and 2008 incarnations expects you to set a property values within your package at runtime using Configurations. SSIS developers tend to have rather a lot of issues with SSIS configurations; in this blog post I am going to highlight one of those problems and how it has been alleviated in SQL Server code-named Denali.   A configuration is a property path/value pair that exists outside of a package, typically within SQL Server or in a collection of one or more configurations in a file called a .dtsConfig file. Within the package one defines a pointer to a configuration that says to the package “When you execute, go and get a configuration value from this location” and if all goes well the package will fetch that configuration value as it starts to execute and you will see something like the following in your output log: Information: 0x40016041 at Package: The package is attempting to configure from the XML file "C:\Configs\MyConfig.dtsConfig". Unfortunately things DON’T always go well, perhaps the .dtsConfig file is unreachable or the name of the SQL Sever holding the configuration value has been defined incorrectly – any one of a number of things can go wrong. In this circumstance you might see something like the following in your log output instead: Warning: 0x80012014 at Package: The configuration file "C:\Configs\MyConfig.dtsConfig" cannot be found. Check the directory and file name. The problem that I want to draw attention to here though is that your package will ignore the fact it can’t find the configuration and executes anyway. This is really really bad because the package will not be doing what it is supposed to do and worse, if you have not isolated your environments you might not even know about it. Can you imagine a package executing for months and all the while inserting data into the wrong server? Sounds ridiculous but I have absolutely seen this happen and the root cause was that no-one picked up on configuration warnings like the one above. Happily in SSIS code-named Denali this problem has gone away as configurations have been replaced with parameters. Each parameter has a property called ‘Required’: Any parameter with Required=True must have a value passed to it when the package executes. Any attempt to execute the package will result in an error. Here we see that error when attempting to execute using the SSMS UI: and similarly when executing using T-SQL: Error is: Msg 27184, Level 16, State 1, Procedure prepare_execution, Line 112 In order to execute this package, you need to specify values for the required parameters.   As you can see, SSIS code-named Denali has mechanisms built-in to prevent the problem I described at the top of this blog post. Specifying a Parameter required means that any packages in that project cannot execute until a value for the parameter has been supplied. This is a very good thing. I am loathe to make recommendations so early in the development cycle but right now I’m thinking that all Project Parameters should have Required=True, certainly any that are used to define external locations should be anyway. @Jamiet

    Read the article

  • How to get full query string parameters not UrlDecoded

    - by developerit
    Introduction While developing Developer IT’s website, we came across a problem when the user search keywords containing special character like the plus ‘+’ char. We found it while looking for C++ in our search engine. The request parameter output in ASP.NET was “c “. I found it strange that it removed the ‘++’ and replaced it with a space… Analysis After a bit of Googling and Reflection, it turns out that ASP.NET calls UrlDecode on each parameters retreived by the Request(“item”) method. The Request.Params property is affected by this two since it mashes all QueryString, Forms and other collections into a single one. Workaround Finally, I solve the puzzle usign the Request.RawUrl property and parsing it with the same RegEx I use in my url re-writter. The RawUrl not affected by anything. As its name say it, it’s raw. Published on http://www.developerit.com/

    Read the article

  • C#: Optional Parameters - Pros and Pitfalls

    - by James Michael Hare
    When Microsoft rolled out Visual Studio 2010 with C# 4, I was very excited to learn how I could apply all the new features and enhancements to help make me and my team more productive developers. Default parameters have been around forever in C++, and were intentionally omitted in Java in favor of using overloading to satisfy that need as it was though that having too many default parameters could introduce code safety issues.  To some extent I can understand that move, as I’ve been bitten by default parameter pitfalls before, but at the same time I feel like Java threw out the baby with the bathwater in that move and I’m glad to see C# now has them. This post briefly discusses the pros and pitfalls of using default parameters.  I’m avoiding saying cons, because I really don’t believe using default parameters is a negative thing, I just think there are things you must watch for and guard against to avoid abuses that can cause code safety issues. Pro: Default Parameters Can Simplify Code Let’s start out with positives.  Consider how much cleaner it is to reduce all the overloads in methods or constructors that simply exist to give the semblance of optional parameters.  For example, we could have a Message class defined which allows for all possible initializations of a Message: 1: public class Message 2: { 3: // can either cascade these like this or duplicate the defaults (which can introduce risk) 4: public Message() 5: : this(string.Empty) 6: { 7: } 8:  9: public Message(string text) 10: : this(text, null) 11: { 12: } 13:  14: public Message(string text, IDictionary<string, string> properties) 15: : this(text, properties, -1) 16: { 17: } 18:  19: public Message(string text, IDictionary<string, string> properties, long timeToLive) 20: { 21: // ... 22: } 23: }   Now consider the same code with default parameters: 1: public class Message 2: { 3: // can either cascade these like this or duplicate the defaults (which can introduce risk) 4: public Message(string text = "", IDictionary<string, string> properties = null, long timeToLive = -1) 5: { 6: // ... 7: } 8: }   Much more clean and concise and no repetitive coding!  In addition, in the past if you wanted to be able to cleanly supply timeToLive and accept the default on text and properties above, you would need to either create another overload, or pass in the defaults explicitly.  With named parameters, though, we can do this easily: 1: var msg = new Message(timeToLive: 100);   Pro: Named Parameters can Improve Readability I must say one of my favorite things with the default parameters addition in C# is the named parameters.  It lets code be a lot easier to understand visually with no comments.  Think how many times you’ve run across a TimeSpan declaration with 4 arguments and wondered if they were passing in days/hours/minutes/seconds or hours/minutes/seconds/milliseconds.  A novice running through your code may wonder what it is.  Named arguments can help resolve the visual ambiguity: 1: // is this days/hours/minutes/seconds (no) or hours/minutes/seconds/milliseconds (yes) 2: var ts = new TimeSpan(1, 2, 3, 4); 3:  4: // this however is visually very explicit 5: var ts = new TimeSpan(days: 1, hours: 2, minutes: 3, seconds: 4);   Or think of the times you’ve run across something passing a Boolean literal and wondered what it was: 1: // what is false here? 2: var sub = CreateSubscriber(hostname, port, false); 3:  4: // aha! Much more visibly clear 5: var sub = CreateSubscriber(hostname, port, isBuffered: false);   Pitfall: Don't Insert new Default Parameters In Between Existing Defaults Now let’s consider a two potential pitfalls.  The first is really an abuse.  It’s not really a fault of the default parameters themselves, but a fault in the use of them.  Let’s consider that Message constructor again with defaults.  Let’s say you want to add a messagePriority to the message and you think this is more important than a timeToLive value, so you decide to put messagePriority before it in the default, this gives you: 1: public class Message 2: { 3: public Message(string text = "", IDictionary<string, string> properties = null, int priority = 5, long timeToLive = -1) 4: { 5: // ... 6: } 7: }   Oh boy have we set ourselves up for failure!  Why?  Think of all the code out there that could already be using the library that already specified the timeToLive, such as this possible call: 1: var msg = new Message(“An error occurred”, myProperties, 1000);   Before this specified a message with a TTL of 1000, now it specifies a message with a priority of 1000 and a time to live of -1 (infinite).  All of this with NO compiler errors or warnings. So the rule to take away is if you are adding new default parameters to a method that’s currently in use, make sure you add them to the end of the list or create a brand new method or overload. Pitfall: Beware of Default Parameters in Inheritance and Interface Implementation Now, the second potential pitfalls has to do with inheritance and interface implementation.  I’ll illustrate with a puzzle: 1: public interface ITag 2: { 3: void WriteTag(string tagName = "ITag"); 4: } 5:  6: public class BaseTag : ITag 7: { 8: public virtual void WriteTag(string tagName = "BaseTag") { Console.WriteLine(tagName); } 9: } 10:  11: public class SubTag : BaseTag 12: { 13: public override void WriteTag(string tagName = "SubTag") { Console.WriteLine(tagName); } 14: } 15:  16: public static class Program 17: { 18: public static void Main() 19: { 20: SubTag subTag = new SubTag(); 21: BaseTag subByBaseTag = subTag; 22: ITag subByInterfaceTag = subTag; 23:  24: // what happens here? 25: subTag.WriteTag(); 26: subByBaseTag.WriteTag(); 27: subByInterfaceTag.WriteTag(); 28: } 29: }   What happens?  Well, even though the object in each case is SubTag whose tag is “SubTag”, you will get: 1: SubTag 2: BaseTag 3: ITag   Why?  Because default parameter are resolved at compile time, not runtime!  This means that the default does not belong to the object being called, but by the reference type it’s being called through.  Since the SubTag instance is being called through an ITag reference, it will use the default specified in ITag. So the moral of the story here is to be very careful how you specify defaults in interfaces or inheritance hierarchies.  I would suggest avoiding repeating them, and instead concentrating on the layer of classes or interfaces you must likely expect your caller to be calling from. For example, if you have a messaging factory that returns an IMessage which can be either an MsmqMessage or JmsMessage, it only makes since to put the defaults at the IMessage level since chances are your user will be using the interface only. So let’s sum up.  In general, I really love default and named parameters in C# 4.0.  I think they’re a great tool to help make your code easier to read and maintain when used correctly. On the plus side, default parameters: Reduce redundant overloading for the sake of providing optional calling structures. Improve readability by being able to name an ambiguous argument. But remember to make sure you: Do not insert new default parameters in the middle of an existing set of default parameters, this may cause unpredictable behavior that may not necessarily throw a syntax error – add to end of list or create new method. Be extremely careful how you use default parameters in inheritance hierarchies and interfaces – choose the most appropriate level to add the defaults based on expected usage. Technorati Tags: C#,.NET,Software,Default Parameters

    Read the article

  • Optional non-system type parameters

    - by Courtney de Lautour
    C#4.0 obviously brings optional parameters (which I've been waiting for, for quite some time). However it seems that because only system types can be const that I cannot use any class/struct which I have created, as an optional param. Is there a some way which allows me to use a more complex type as an optional parameter. Or is this one of the realities that one must just live with?

    Read the article

  • How to make a parameter optional in WSDL?

    - by user305069
    I have a WebService API which needs 2 of its parameters to be optional in the WSDL public wsProxy[] Insert(wsProxy[] proxies, string loginname, string password, bool returnNewData) { //code here } I need to a way to show loginname and password as optional in the WSDL. Is there any way to do this in C#. Can I maybe add an tag in front of the parameters like this [optional]loginname? I have been looking around but haven't been able to find anything so far.

    Read the article

  • HTML: Include, or exclude, optional closing tags?

    - by Ian Boyd
    Some HTML1 closing tags are optional, i.e.: </HTML> </HEAD> </BODY> </P> </DT> </DD> </LI> </OPTION> </THEAD> </TH> </TBODY> </TR> </TD> </TFOOT> </COLGROUP> Note: Not to be confused with closing tags that are forbidden to be included, i.e.: </IMG> </INPUT> </BR> </HR> </FRAME> </AREA> </BASE> </BASEFONT> </COL> </ISINDEX> </LINK> </META> </PARAM> Note: xhtml is different from HTML. xhtml is a form of xml, which requires every element have a closing tag. A closing tag can be forbidden in html, yet mandatory in xhtml. Are the optional closing tags ideally included, but we'll accept them if you forgot them, or ideally not included, but we'll accept them if you put them in In other words, should i include them, or should i not include them? The HTML 4.01 spec talks about closing element tags being optional, but doesn't say if it's preferable to include them, or preferable to not include them. On the other hand, a random article on DevGuru says: The ending tag is optional. However, it is recommended that it be included. The reason i ask is because you just know it's optional for compatibility reasons; and they would have made them (mandatory | forbidden) if they could have. Put it another way: What did HTML 1, 2, 3 do with regards to these, now optional, closing tags. What does HTML 5 do? And what should i do? Footnotes 1HTML 4.01

    Read the article

  • avoiding the tedium of optional parameters

    - by Kyle
    If I have a constructor with say 2 required parameters and 4 optional parameters, how can I avoid writing 16 constructors or even the 10 or so constructors I'd have to write if I used default parameters (which I don't like because it's poor self-documentation)? Are there any idioms or methods using templates I can use to make it less tedious? (And easier to maintain?)

    Read the article

  • C# 4.0: Named And Optional Arguments

    - by Paulo Morgado
    As part of the co-evolution effort of C# and Visual Basic, C# 4.0 introduces Named and Optional Arguments. First of all, let’s clarify what are arguments and parameters: Method definition parameters are the input variables of the method. Method call arguments are the values provided to the method parameters. In fact, the C# Language Specification states the following on §7.5: The argument list (§7.5.1) of a function member invocation provides actual values or variable references for the parameters of the function member. Given the above definitions, we can state that: Parameters have always been named and still are. Parameters have never been optional and still aren’t. Named Arguments Until now, the way the C# compiler matched method call definition arguments with method parameters was by position. The first argument provides the value for the first parameter, the second argument provides the value for the second parameter, and so on and so on, regardless of the name of the parameters. If a parameter was missing a corresponding argument to provide its value, the compiler would emit a compilation error. For this call: Greeting("Mr.", "Morgado", 42); this method: public void Greeting(string title, string name, int age) will receive as parameters: title: “Mr.” name: “Morgado” age: 42 What this new feature allows is to use the names of the parameters to identify the corresponding arguments in the form: name:value Not all arguments in the argument list must be named. However, all named arguments must be at the end of the argument list. The matching between arguments (and the evaluation of its value) and parameters will be done first by name for the named arguments and than by position for the unnamed arguments. This means that, for this method definition: public static void Method(int first, int second, int third) this call declaration: int i = 0; Method(i, third: i++, second: ++i); will have this code generated by the compiler: int i = 0; int CS$0$0000 = i++; int CS$0$0001 = ++i; Method(i, CS$0$0001, CS$0$0000); which will give the method the following parameter values: first: 2 second: 2 third: 0 Notice the variable names. Although invalid being invalid C# identifiers, they are valid .NET identifiers and thus avoiding collision between user written and compiler generated code. Besides allowing to re-order of the argument list, this feature is very useful for auto-documenting the code, for example, when the argument list is very long or not clear, from the call site, what the arguments are. Optional Arguments Parameters can now have default values: public static void Method(int first, int second = 2, int third = 3) Parameters with default values must be the last in the parameter list and its value is used as the value of the parameter if the corresponding argument is missing from the method call declaration. For this call declaration: int i = 0; Method(i, third: ++i); will have this code generated by the compiler: int i = 0; int CS$0$0000 = ++i; Method(i, 2, CS$0$0000); which will give the method the following parameter values: first: 1 second: 2 third: 1 Because, when method parameters have default values, arguments can be omitted from the call declaration, this might seem like method overloading or a good replacement for it, but it isn’t. Although methods like this: public static StreamReader OpenTextFile( string path, Encoding encoding = null, bool detectEncoding = true, int bufferSize = 1024) allow to have its calls written like this: OpenTextFile("foo.txt", Encoding.UTF8); OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096); OpenTextFile( bufferSize: 4096, path: "foo.txt", detectEncoding: false); The complier handles default values like constant fields taking the value and useing it instead of a reference to the value. So, like with constant fields, methods with parameters with default values are exposed publicly (and remember that internal members might be publicly accessible – InternalsVisibleToAttribute). If such methods are publicly accessible and used by another assembly, those values will be hard coded in the calling code and, if the called assembly has its default values changed, they won’t be assumed by already compiled code. At the first glance, I though that using optional arguments for “bad” written code was great, but the ability to write code like that was just pure evil. But than I realized that, since I use private constant fields, it’s OK to use default parameter values on privately accessed methods.

    Read the article

  • F# Optional Record Field

    - by akaphenom
    I have a F# record type and want one of the fields to be optional: type legComponents = { shares : int<share> ; price : float<dollar / share> ; totalInvestment : float<dollar> ; } type tradeLeg = { id : int ; tradeId : int ; legActivity : LegActivityType ; actedOn : DateTime ; estimates : legComponents ; ?actuals : legComponents ; } in the tradeLeg type I owuld like the the actuals field to be optional. I cant seem to figure it out nor can I seem to find a reliable example on the web. It seem like this sohuld be easy like let ?t : int = None but i realy can't seem to get this to work. Ugh - thank you T

    Read the article

  • Naming Optional Parameters in VSB

    - by SteveNeedsSheetNames
    In Visual Basic, I have Functions with a lot of Optional arguments. I would like to be able to pass just a few of these Optional arguments to a Function without having to use numerous commas and spaces to get to the ones I want. Somewhere I saw a way to name params such as OptVar:=val, but that does not seem to work. Just wondering if there is a way to do this. This would help readability. Thanks in advance for the replies.

    Read the article

  • Passing optional parameter by reference in c++

    - by Moomin
    I'm having a problem with optional function parameter in C++ What I'm trying to do is to write function with optional parameter which is passed by reference, so that I can use it in two ways (1) and (2), but on (2) I don't really care what is the value of mFoobar. I've tried such a code: void foo(double &bar, double &foobar = NULL) { bar = 100; foobar = 150; } int main() { double mBar(0),mFoobar(0); foo(mBar,mFoobar); // (1) cout << mBar << mFoobar; mBar = 0; mFoobar = 0; foo(mBar); // (2) cout << mBar << mFoobar; return 0; } but it crashes at void foo(double &bar, double &foobar = NULL) with message : error: default argument for 'double& foobar' has type 'int' Is it possible to solve it without function overloading? Thanks in advance for any suggestions. Pawel

    Read the article

  • bonding module parameters are not shown in /sys/module/bonding/parameters/

    - by c4f4t0r
    I have a server with Suse 11 sp1 kernel 2.6.32.54-0.3-default, with modinfo bonding i see all parameters, but under /sys/module/bonding/parameters/ not modinfo bonding | grep ^parm parm: max_bonds:Max number of bonded devices (int) parm: num_grat_arp:Number of gratuitous ARP packets to send on failover event (int) parm: num_unsol_na:Number of unsolicited IPv6 Neighbor Advertisements packets to send on failover event (int) parm: miimon:Link check interval in milliseconds (int) parm: updelay:Delay before considering link up, in milliseconds (int) parm: downdelay:Delay before considering link down, in milliseconds (int) parm: use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int) parm: mode:Mode of operation : 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp) parm: primary:Primary network device to use (charp) parm: lacp_rate:LACPDU tx rate to request from 802.3ad partner (slow/fast) (charp) parm: ad_select:803.ad aggregation selection logic: stable (0, default), bandwidth (1), count (2) (charp) parm: xmit_hash_policy:XOR hashing method: 0 for layer 2 (default), 1 for layer 3+4 (charp) parm: arp_interval:arp interval in milliseconds (int) parm: arp_ip_target:arp targets in n.n.n.n form (array of charp) parm: arp_validate:validate src/dst of ARP probes: none (default), active, backup or all (charp) parm: fail_over_mac:For active-backup, do not set all slaves to the same MAC. none (default), active or follow (charp) in /sys/module/bonding/parameters ls -l /sys/module/bonding/parameters/ total 0 -rw-r--r-- 1 root root 4096 2013-10-17 11:22 num_grat_arp -rw-r--r-- 1 root root 4096 2013-10-17 11:22 num_unsol_na I found some of this parameters under /sys/class/net/bond0/bonding/, but when i try to change one i got the following error echo layer2+3 > /sys/class/net/bond0/bonding/xmit_hash_policy -bash: echo: write error: Operation not permitted

    Read the article

  • Problem inserting parameters into a function

    - by SoLoGHoST
    Ok, I am trying to place parameters into a function that is called like so: $parameters['function']($parameters['params']); Here is the function and the parameters that I need to be placed into this: $parameters['function'] = 'test_error'; $parameters['params'] = array(0 => $txt['sometext'], 1 => 'critical', 2 => true); The test_error function takes 3 parameters: The error to output The type of error noted within a string value ('general', 'critical', etc. etc.). Whether it should be echoed or not. Here is the output I get: Here is a test error.ArraycriticalArray1 I know this function works perfect, but it only gives me the 1st parameter returned from it. What am I doing wrong here with the $parameters['params']??

    Read the article

  • Design for object with optional and modifiable attributtes?

    - by Ikuzen
    I've been using the Builder pattern to create objects with a large number of attributes, where most of them are optional. But up until now, I've defined them as final, as recommended by Joshua Block and other authors, and haven't needed to change their values. I am wondering what should I do though if I need a class with a substantial number of optional but non-final (mutable) attributes? My Builder pattern code looks like this: public class Example { //All possible parameters (optional or not) private final int param1; private final int param2; //Builder class public static class Builder { private final int param1; //Required parameters private int param2 = 0; //Optional parameters - initialized to default //Builder constructor public Builder (int param1) { this.param1 = param1; } //Setter-like methods for optional parameters public Builder param2(int value) { param2 = value; return this; } //build() method public Example build() { return new Example(this); } } //Private constructor private Example(Builder builder) { param1 = builder.param1; param2 = builder.param2; } } Can I just remove the final keyword from the declaration to be able to access the attributes externally (through normal setters, for example)? Or is there a creational pattern that allows optional but non-final attributes that would be better suited in this case?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >