.net

"Token Text in state EndRootElement would result in an invalid XML document"

I'm seeing this exception message coming from XslCompiledTransform.Transform(), but after handling the exception the XSL transform still appears to have been successful. The full exception message is: Token Text in state EndRootElement would result in an invalid XML document. Make sure that the ConformanceLevel setting is set t...

What is the best way to teach you and your boss C#?

My boss wants to "get back into programming" by making an internal web application. I've got lots of experience with php and mvc frameworks, but he's doesn't want to learn php, he wants to learn c# as it probably will be more useful to him down the road (I can't disagree.) I think I'll be ok with tutorials and code snippets I find online...

How do I do a deep copy of an element in LINQ to XML?

I want to make a deep copy of a LINQ to XML XElement. The reason I want to do this is there are some nodes in the document that I want to create modified copies of (in the same document). I don't see a method to do this. I could convert the element to an XML string and then reparse it, but I'm wondering if there's a better way. ...

How can you change Network settings (IP Address, DNS, WINS, Host Name) with code in C#

I am developing a wizard for a machine that is to be used as a backup of other machines. When it replaces an existing machine, it needs to set its IP address, DNS, WINS, and host name to match the machine being replaced. Is there a library in .net (C#) which allows me to do this programatically? There are multiple NICs, each which nee...

WCF WebHttp Mixed Authentication (Basic AND Anonymous)

All of this is pertaining to WebHttp binding, hosted in a custom Service Host (IIS is not an option at this time). I've implemented a custom UserNamePasswordValidator, and a custom IAuthorizationPolicy. When I configure the endpoint's binding to use Basic authentication, everything works just as I'd like (custom principal, custom roles...

How to determine if .NET code is running in an ASP.NET process?

I have an instance of a general purpose class that will be executed both under ASP.NET and a stand alone program. This code is sensative to the process where it is being run - that is, there are certin methods that should not called if running under ASP.NET. How do you determine if the code is executing in an ASP.NET process? The soluti...

ASP.NET localization with Page Methods/Web Services via AJAX

That's a mouthful... Here's the issue, we're doing some client-side validation via AJAX calls to page methods (which are essentially web services). We've also added a drop-down on the page to choose your language and have created a class that inherits from Page that initializes localization based on the drop-down selection. When page ...

For a typical Web 2.0 Social Application - Java vs C#

For a product in long run (may be 0.5-1 million users) is it good to use java instead of .net from the cost/profitability perspective. To elaborate more..consider web farm scenario in which one will have to purchase windows + Sql server + some antivirus licenses for .net applications. But for java it's almost free. What points should I c...

How do I capture inputoutput parameter value after a Formview Insert template runs stored procedure in .NET 2.0?

I have a formview that executes a insert stored procedure through a table adapter as normally done. Except when the insert fails a output parameter on the sp called error_msg is set to "Insert failed because XXXX is required". how do I capture this value and print it on the screen for the user? I can't seem to find locate it. ...

In LINQ how to find a distinct item that is joining 2 tables?

Given the Below Tables. How do I get the Distinct name given the other ID of 76 in LINQ? **Table S** SID OtherID ------------------------------ 1 77 2 76 **Table Q** QID SID HighLevelNAme LoweLevelName --------------------------------------- 10 1 Name1 Engine 11 1 Name1 ...

What is a "Nested Quantifier" and why is it causing my regex to fail?

I have this regex I built and tested in regex buddy. "_ [ 0-9]{10}+ {1}+[ 0-9]{10}+ {2}+[ 0-9]{6}+ {2}[ 0-9]{2}" When I use this in .Net C# I receive the exception "parsing \"_ [ 0-9]{10}+ +[ 0-9]{10}+ +[ 0-9]{6}+ [ 0-9]{2}\" - Nested quantifier +." What does this error mean? Apparently .net doesn't like the expression. Here is ...

Capturing data from a .Net web-service that fails with an HTTP 500 error code

I have a .net web-service hosted in IIS 6.0 that periodically fails with an http 500 because a client connects to it with data that does not match the wsdl. Things like having an element specified in a method as being of type int and the inbound xml element contains a decimal number. WSDL element definition: <s:element minOccurs="1" m...

View need to go Winform to Webform, what is your advices?

Hi, Our application is well structured (well we did our best!) and we have split the Model from the View, Now, we need to let some information to our client with a web access. We would like to build something small with IIS and some webform. Here some information you might think are useful: Our controller have Thread of database quer...

Are immutable arrays possible in .NET?

Is it possible to somehow mark a System.Array as immutable. When put behind a public-get/private-set they can't be added to, since it requires re-allocation and re-assignment, but a consumer can still set any subscript they wish: public class Immy { public string[] { get; private set; } } I thought the readonly keyword might do t...

Exact time between 2 DateTime?

I would like to know many minutes between 2 dates? Example : Now - tommorow at the exact time would return me 1440. ...

add menu item to default context menu

I'd like to add a menu item to the default ContextMenu of a RichTextBox. I can create a new context menu but then I loose the spell check suggestions that show up in the default menu. Is there a way to add an item without re-implementing everything? ...

Validate image from file in C#

I'm loading an image from a file, and I want to know how to validate the image before it is fully read from the file. string filePath = "image.jpg"; Image newImage = Image.FromFile(filePath); The problem occurs when image.jpg isn't really a jpg. For example, if I create an empty text file and rename it to image.jpg, an OutOfMemory Ex...

LINQ to SQL DataContext.Translate and properties with name different than the source.

I am working with some tables where I want the C# class to have a different property name than the underlying table column. However, when I use the Translate method to read the results, the properties that don't match the source name never get populated. Even when I use Linq to generate the SQL. For instance, my table is defined in the ...

networking in .net/C#

Could somebody please point me in the right direction for learning how to do networking in C#/.net 3.5? Code samples and explanations are welcome. Basically I am looking for how to do asynchronous/multithreaded server/client models. I am fairly comfortable with the basics in how to accomplish this in C++ with WinSock but though all of m...

Assembly "is not signed correctly." Warning

I have a mobile .NET solution and decided to sign the assemblies. Compilation completes without errors but gives the warning 'CompactUI.Business.PocketPC.asmmeta, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not signed correctly. The application is working fine but I can't open the designer for forms using this assembly an...