.net

Why do I have to specify the "out" keyword in C#?

Before I ask my question, please take a look at this example function: DateTime.TryParse("01/01/2000", out oDate) Why do I need to specify the out keyword? Shouldn't the compiler know this from the function's definition? I'm asking this out of pure curiosity in the hope that I will learn something new about the compiler. I should al...

Object Initialization and "Named Constructor Idiom"

Ok. So I have a list of values, and I'd like to do something like the following: MyObjectValues .Select(currentItems=>new MyType() { Parameter1 = currentItems.Value1, Parameter2 = currentItems.Value2 }); So here's the problem. I need the above example to work with named constructors, such as: MyObjectValues .Select(curren...

Debug in VS as non-admin

I'm doing some WinForms development, running XP and VS 2005 (ancient, I know). I'd like to make sure my application can run without admin rights, but I'm too lazy to try to run VS as a non-admin, and I don't want to log in and out to test my app. Is there a way I can just debug as a non-admin? Is there a set of code access securit...

Memory Leak in C#

Is it ever possible in a managed system to leak memory when you make sure that all handles, things that implement IDispose are disposed? Would there be cases where some variables are left out? ...

Consuming .NET webservice in Java (metro) - XMLNode/XMLDocument consumption?

I am a bit rusty in my Java, and this is my first time using metro/JAX-WS, so if this is a dumb question I apologize. I have to write a client that consumes a .NET webservice. I've got the basics down; I have generated the wrappers from the WSDL, and I can create my object and port and make a call and get a response. Widgets d = new ...

Searching NTFS directory .NET

I would like to write a web page where users can search a directory on NTFS for certain criteria and display the results. Does the directory have to be indexed? Is there a .NET accessible windows search API that I can use to query the directory? ...

Current line number from a System.Xml.XmlReader (C# & .Net)

Does anyone know how I can get the current line number of an System.Xml.XmlReader? I am trying to record where in a file I find Xml elements. ...

Different orientation in a Multiple page PrintDocument (How to)

I have a PrintDocument that has several pages. One page in that document must be in a Landscape orientations instead of Portrail. As the PrintPage event is triggered for each page on the document... at the very begining of that event handler I set the PrintPageEventArgs.PageSettings.Landscape to true. That doesn't works on THAT page......

Problem Connecting to WCF Service on a Server

I have set up a WCF service on a server which lives in its own Workgroup. I've tried to make a TCP/IP connection to it from a client that lives on the corporate domain. When I try to open a connection, I get a SecurityNegotiationException with the message: "A remote side security requirement was not fulfilled during authentica...

What is the best way to deploy authenticated autoupdates in a .NET application?

Currently applications are deployed only to my office of 40 employees or so. ClickOnce works great for this as everyone has network access or VPN access which makes updating pretty straightforward. Now, it has been tasked to me to figure out the best way to deploy these applications to res of the company. ClickOnce would work but the ...

Detect cycles in a geneology graph during a Depth-first search

I'm loading horse genealogical data recursively. For some wrong sets of data my recursion never stops... and that is because in the data there are cycles. How can I detect those cycles to stop recursing? I thougth of while recursing mantain a hashTable with all "visited" horses. But that will find some false positives, because a horse ...

How to fix this linq to sql query that has no support translation to sql?

Hi folks. i've got a LinqToSql query with a custom extension method at the end. this extension method is erroring when I try to linq2sql tries to generate the sql statement. Error: Method 'System.Collections.Generic.IList1[System.String] ToListIfNotNullOrEmpty[String](System.Collections.Generic.IEnumerable1[System.String])' h...

Binding dropdown list in a gridview edit item template

i can bind the dropdownlist in the edit item template. The drop down list is having null values. protected void grdDevelopment_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList drpBuildServers = new DropDownList(); if (grdDevelopment.EditIndex == e.Row.RowIndex) { drpBuildServers = (DropDown...

How new keyword works in c#

There's a class which is compiled into a dll //HeaderFile.h //version 1.0 class __declspec(dllexport) A { int variable; //member functions omitted for clarity }; //implementation file omitted for clarity You build an exe which uses above class from the dll it was compiled into #include "HeaderFile.h" int main() { A *obj = ...

I get this JavaScriptSerializer.Deserialize Exception, how do I fix it?

System.Exception: There was an error reading the city list for CANANDA ---> System.ArgumentException: Unrecognized escape sequence. (1056): {code: "CA",cities: [{name: "Abbotsford",lat: 49029998,lon: -122370002},{name: "Calgary",lat: 51119998,lon: -114019996},{name: "Edmonton",lat: 53299999,lon: -113580001},{name: "Halifax",lat: 448800...

What is the purpose of "remove unused references"

I have read that removing unused references makes no difference to the compiler as it ignores assemblies that are not being referenced in the code itself. But I find it hard to believe because then, what is the real purpose of Removing unused references? It doesn't have any noticeable effect on the size of the generated assembly or othe...

Creating what is equivalent to an ISAPI extension for IIS7

I've searched the IIS7 MSDN database but can't find any concrete material on how to create custom C#.NET extensions for IIS7, I know that previously in IIS6 you had to write an ISAPI extension in C++ if you wanted to say plug in your own scripting language for websites (this is sort of what I want to do) but in IIS7 you're supposed to be...

Strange behaviour XmlDocument.LoadXML and GetElementByID, how to delcare string with quotation mark

Here's some c# code string webPageStr = @"<html><body><div id=""content"">good content</div><div id=""badcontent"">bad content</div></body></html>"; XmlDocument webPage = new XmlDocument(); webPage.LoadXml(webPageStr); XmlElement divElement = webPage.GetElementById("content"); and divElement is equal null and i don't know why I ha...

How does Stackoverflow escape tag names in urls

I want to generate a url from a tag name. In my view (asp.net mvc) I have the following: <%= Html.ActionLink(Html.Encode(tagName), "tagged" //action, "posts" //controller, new {tagName=Html.UrlEncode(tagName)} //querystring argument, new {@class="tag"} //html attributes) %> But this generates the following URL if the tagName i...

DataContractSerializer missing from the .NET Compact Framework

It appears that the DataContractSerializer isn't available in the .NET Compact Framework. I found this quite surprising, as I consider DataContractSerializer to be the Holy Grail of serialization, and one of the most widely useful classes introduced in .NET 3. Is there a way to get the same functionality under the Compact Framework, tha...