.net

Parsing xml string to an xml document fails if the string begins with <?xml... ?> section

I have an XML file begining like this: <?xml version="1.0" encoding="utf-8"?> <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"&gt; <DataSources> When I run following code: byte[] fileContent = //gets bytes ...

Missing nodes cause a null exception crash linq to xml

I get a null exception on this because MYTAG1 doesn't exist. I understand that this is because Element("MYTAG1") is null and calling Elements("MYTAG2") on it wont work. How do I deal with this to prevent the crash? var myItems = from myNode in Nodes.Element("MYTAG1").Elements("MYTAG2") select new EPTabl...

WCF NetTcpBinding Buffered vs Streamed performance problems

I wrote a WCF service that should transform any size of files, using the Streamed TransferMode in NetTcpBinding, and System.IO.Stream object. When running performance test, i found significant performance problem. Then I decided to test it with Buffered TransferMode and saw that performance is two times faster! Because my service shoul...

Why do we need boxing and unboxing in C#?

Though I know what boxing and unboxing is. But I can't comprehend the real use of it. Why and where should I use it. short s=25; object objshort=s; //Boxing short anothershort=(short)objshort; //UnBoxing Please help. Thanks in advance. ...

No control created on page_load

Hello, I have a Asp page containing 2 radio buttons and other textbox and labels. The things is that I have to make some of them disapear (not visible) when a radio button is selected. I thought about using a ControlCollection and adding the control I need to make invisible to it. But as soon as I had them to the ControlCollection, they...

How to Target older versions of framework using VS2005?

I have VS2005 and VS2008 installed on my pc. I have .NET Framework 2.0 SP2, 3.0, 3.0 SP2, and 3.5 SP1 I am able to selection which Framework to use in VS 2008 from the drop down window, but I'm curious how I set which framework I want to target a project for in VS 2005. I obviously dont want to uninstall frameworks because I would sti...

What are the key features/benefits of RIA Services?

I am currently researching .NET RIA Services however I am having trouble finding a definitive list of the benefits of RIA services compared to plain WCF to Silverlight, or event a list of the key components that make up RIA Services. I also find it hard to see where RIA services sits in the development model and exactly what it provides ...

Access Images from external storage in ASP.NET

Hi I have an ASP.NET site in a web server and the images are stored in NAS (some kind of lacie external storage), I tried UNC and other things but no success. how can I access images from external storage in ASP.NET Thanks Update: The images are reachable from the server but when I try to access in ASP.NET throws me error. ...

How to get referenced .dll's path in web project

Hi, I have a C#.net class library that references a folder and the files in it. I've added this library as a reference in my ASP.NET web project and I can't figure out how i'm supposed to get the path to this folder. Anyone know? Or would you have to pass the Server.MapPath in from the website? Cheeres ...

BLAST Searches from C#/.NET?

Can anyone recommend a library for performing BLAST searches from a C#/.NET application? Perl, Ruby, Python, and Java have libraries that support this type of functionality, but I'm having a hard time finding one for .NET. Thanks! ...

Returning a list of lists from a webservice

Can I have a webservice method that returns List<List<MyObject>> in .net? ...

WinForms Form Hangs on Startup on One Machine

For my VB.NET application, I'm using the windows installer that came with Visual Studio. I can successfully install and run my program on any computer in our office except for one. On this particular machine, my program will stall for about 30 seconds before being able to load the main form. When I start up the task manager, the CPU i...

Using .Net, is it possible to get the list of all "running/active" instances from a specific type?

I would like to know if it is possible to get all the objects running from an application/assembly/appdomain of a specific type... I don't think reflection would help in this case as I need an object before hand. However, I want to got the other way: from a type I want all the objects created from it. Is this possible with .Net? ...

FTPListener in .NET

I am unittesting a bit of code that can fetch files either from the local file system, or from http or ftp. To unittest it I created a simple method that uses the HTTPListener class from the BCL to run a one-off webserver on a different thread, it just serves a byte array that I send in and then shuts down. (See code for this below). I...

RhinoMocks - Specifying return for functions called later

Using RhinoMocks - how can I say "whenever some function is called from now on - it should return some value". I'd like to say something like this: fakeCalculator.WhenCalled(factory => factory.AddNumbers(1, 2)).Return(3); And then - when the AddNumbers function is called with 1 and 2 - it will return 3. I.e. I want to define this ...

Calling stored procedures, passing NULL values, dealing with boolean values

When calling a stored procedure I am concatenating values together, my question is how do you call a stored procedure but send a 'NULL' value in one of the params? Lets say that AID = null, but if I pass that to my query I get an error?! QueryConn.Execute("Search_Res " & Count & "," & AccessList("InvoiceLevel") & "," & AID) Ok, so my...

WCF Service Shutdown

I have a single instance WCF service class that is self hosted using a Windows service. I set up the service host in the OnStart event and I close the service in the OnStop event. In the service class I implement a destructor and I have some clean-up code in there. Essentially the clean-up code serialises some internal objects to disk f...

Closing a stream after an exception

I open a stream and then deserialize the data in the stream. However, I added a member to the SavedEventSet object so now when I try to open an old file, it throws the exception on the deserialization line. This is fine with me (for now) but the problem is that I handle the exception, but never close the stream (because the exception o...

What is the alternative of bigint in c#

Hi, what I am suppose to use when handling a value in c#, which is bigint SQLSERVER DB ? Thanks ...

Web Service Request failure Recovery time

I have C# application that consumes a web service. The problem I have is that if a request fails because the service is unavailable, I get weird behavior when attempting future requests when I know the service is available. Example Sequence of events: 1. Application is started with service unavailable. 2. Request[1] is made t...