.net

Programmatic data in .NET Winforms DataGrid

I'm getting a weird behavior with a datagrid. No matter what I do, it's ordering the columns arbitrarily and adding all the columns in the objects. I'm using .NET 3.5, with a winforms datagrid. The Datasource is set at runtime, not design time. I've tried defining the columns in the GDI, but it ignores the order. Even if I only defi...

Custom Aggregate Functions in Reports.

I have daily records of production per category, i.e. category A: 80 tons. Each report row will look like this: Daily Week to Date Month to Date Actual Plan Var Actual Plan Var Actual Plan Var Category A 100 110 -10 230 300 -70 900 1200 -30...

Strange behaviour with a pl/sql query and .net

Hi I run this query to read the count of the Records with an output parameter using OracleCommand: var query = "declare MyCount number; begin SELECT COUNT(*) INTO :MyCount FROM T_ISSUE; end;"; this one works fine. But if I split the query into two lines like this: var query = @"declare MyCount number; begin SELECT CO...

How do I create a custom network connection entry?

I have a Sprint MiFi 3G router that exposes its current signal strength over HTTP. I've developed a very simple tray application that displays this. However, what I would really like to do is create a custom network connection entry so the router's 3G signal strength (along with the current network version) displays when clicking on the ...

XPathNavigator.SetValue Throws NotSupportedException

I have the following code, whose last line results in a NotSupportedException on every execution, and I haven't found a way around it. This hypothetical analogous code finds a "book" with a specific title, with the goal of updating it to the new title. It does find the correct node, but fails to update it. XPathDocument xpathDoc = new X...

Writing XML to memory instead of disk

How do i go about writing the results of a FOR XML PATH stored procedure into memory rather than a file on disk? Current way of doing things: private void GetChartData(string OC_Ttl1, string OC_Ttl2, string OC_OL31) { OC_Ttl_1 = OC_Ttl1; OC_Ttl_2 = OC_Ttl2; OC_OL3_1 = OC_OL31; //Output xml DataSet orgDataSet = new ...

.Net int() equivalent in PHP

I'm converting a .net app to php. What would be the php equivalent of int(6.22555445656) in php? ...

Using a User Control from Another Project

I have built a user control in a project that I want to re-use in a separate project. I had seen similar attempts successfully accomplished by adding a reference to the original project and then registering the control via: <%@ Register Assembly="AssemblyName" Namespace="AssemblyName.Namespace" TagPrefix="xxx" %> I did something simi...

Is it bad to use nested Try..Catch blocks like this?

Is this a bad idea? Is there a better way to achieve the same effect? // assume that "name" is a string passed as a parameter to this code block try { MainsDataContext dx = new MainsDataContext(); try { Main m = dx.Main.Single(s => s.Name == name); return m.ID; } catch (InvalidOperationException) ...

Offline Resources on Dynamic Data and Entity Framework

Horrors, I'm stuckk with only 3G access to the net, so I would like to download some solid references to Entity Framework and Dynamic Data that I can get by with while offline, as I'm no expert on these. ...

Best Serialization for a scenario where performance is paramount and data form is unimportant in .NET?

Which serialization should I use? I need to store a large Dictionary with 100000+ elements, and I just need to save and load this data directly without caring whether it's binary or whether it's formatted or not. Right now I am using the BinarySerializer but not sure if it's the most effective? Please suggest better alternatives in th...

wsdl.exe-generated WCF service exposing private fields in wsdl

I'm doing some wsdl- and client-first development in C# with WCF (the wsdl and client already exist, I'm building the server-side,) and I'm having an odd issue. I used wsdl.exe to generate a contract from my .wsdl, and I'm able to build it and host the WCF service as a Windows service. However, the wsdl I get from http://localhost/Servi...

Which serializer is most forgiving for changes to the serialized types in .NET?

I noticed the XmlSerializer is more forgiving to adding new members, removing existing ones, etc to the serialized types. When I did this with the BinaryFormatter, and tried to deserialize the old data, it threw an exception. What other alternatives are there for forgiving options, i.e. one that doesn't throw an exception just uses def...

Get name and version info of every ActiveX component registered on PC (.NET)

I'm looking for a quick and dirty way to get a list of all ActiveX components regeistered on a PC along with the version information. Basically I need the long name of the component (ex:Microsoft Excel 12.0 object Library) , Filename (ex:EXCEL.EXE), and version number. I want to get this programmatically using .NET. ...

Compilation Error in ASP.NET Code when adding a Literal Control

I'm trying to format a literal control on a code-behind page: BillerLiteral.Text = "<p class="'no-margin'"/>" + attendee1.FirstName + " " + attendee1.LastName + "</p> <p class=""no-margin"">" + attendee1.Address1 + "," + attendee1.Address2 + "</p><p class=""margin"">" + attendee1.City + "," + attendee1.State + " " + attendee1.ZipCode...

How does Returning a Struct as an Interface work?

The following code works, but I can't figure out what's going on memory-wise. Where and how is the struct value t copied? interface ITest { void Hello(); } struct STest : ITest { public void Hello() { Console.WriteLine("Hello"); } } static ITest Make() { STest t = new STest(); return t; } static void Main(string[] arg...

What am I doing wrong with this use of StructLayout( LayoutKind.Explicit ) when calling a PInvoke struct with union?

The following is a complete program. It works fine as long as you don't uncomment the '#define BROKEN' at the top. The break is due to a PInvoke failing to marshal a union correctly. The INPUT_RECORD structure in question has a number of substructures that might be used depending on the value in EventType. What I don't understand i...

C#: What is the fastest way to generate a unique filename?

I've seen several suggestions on naming files randomly, including using System.IO.Path.GetRandomFileName() or using a System.Guid and appending a file extension. My question is: What is the fastest way to generate a unique filename? ...

Convert text to .resources file

I created a new VS solution which needs to contain a modified subset of files from another solution. Both solutions have a default namespace of "Microsoft.Windows.Controls". The assembly from the old solution is named "WPFToolkit", and the new assembly name is "DatePicker". One of the files I copied over to the new solution is an embe...

Accessing a Static Method in C#

I have this class: public static class CsvWriter { private static StreamWriter _writer = new StreamWriter(@"c:\temp\ssis_list.csv"); public static StreamWriter Writer { get { return _writer; } } } This is being called from another class class Program { ... static void GetC...