.net

Create generic delegate using reflection

I have the following code: class Program { static void Main(string[] args) { new Program().Run(); } public void Run() { // works Func<IEnumerable<int>> static_delegate = new Func<IEnumerable<int>>(SomeMethod<String>); MethodInfo mi = this.GetType().GetMethod("SomeMethod").MakeGeneri...

ADO.NET data table vs. data reader

Datareader is more efficient that datatable if you need only show some data but not manipulate it. However , to get a datareader from dataaccess layer I should left the connection object open.I think this is also very big efficiency problem. Is there any approach to this to take the full advantage of datareader? ...

"Namespace Manager or XsltContext needed" when {Binding XPath=ns:Foo}

I'm binding DataTemplates to an XmlDataProvider. Since the XML data in question makes use of namespaces, I've also attached an XmlNamespaceManager to the XmlDataProvider and mapped a prefix to it. When Binding to an XPath fresh off the root of the XmlDataProvider, the namespace prefix is understood just fine and I get results. However,...

Is there an easy way to generate code from a text file?

I am currently working on a project that is accessing a piece of hardware using tons of hard coded memory locations. These locations can change based upon the electrical engineer's whim, so I'm looking to generate code from the engineer's memory map. Let's say the map is a simple text file like: Name, Type, Address, Description Foo, i...

LinkButton in a DataList

I have a datalist and in its header template I have a linkbutton.In my codebehind file I wrote as I've always written: ((LinkButton)(DataList1.FindControl("LinkButton1"))).Enabled = false; but this gives me the error: Object reference not set to an instance of an object. How can I access this linkbutton? ...

How secure are Resources in .NET?

How hard would it be to retrieve embedded resources from a .NET application, from outside the application itself? Even if the resources are compressed and trivially encrypted, how difficult is it to retrieve them using a tool? (I am not concerned with the protection of the data per se, just the methods of retrieval of the resource itself...

How Can I Compare Any Numeric Type To Zero In C#

I would like to create a function that checks if a numeric value passed as an argument has a value greater than zero. Something like this: public bool IsGreaterThanZero(object value) { if(value is int) { return ((int)value > 0); } else if(value is float) { // Similar code for float } return f...

using Linq To Sql to save to an SDF (local database file) in .Net

HI, I am trying to save some data to my .sdf file using a LinqToSql object. I have a table as follows - PersonId int not null pk forename nvarchar(4000) surname nvarchar(4000) Birthdate DateTime IsMale bit Biography nvarchar(4000) I am inserting a value into all fields apart from the PersonId column (set to identity, increment). I a...

Distortion when resizing/scaling WPF Image

I have a program that displays an image, and the user can resize the image in the window (e.g. by rolling the mouse wheel). I scale the image using a RenderTransform, like this: <Image x:Name="CurrentImage"> <Image.RenderTransform> <TransformGroup> <TranslateTransform x:Name="Translate" X="0" Y="0"/> ...

Automatic LINQ to SQL entities validation

Is there anyway to make LINQ entities validate automatically according to the properties of the datatypes defined in the database? For example, if my property maps to a varchar(40) not null in the database, automatically validate the property to be not null and 40 length? ...

.NET Runtime Object Browser.

Is there a framework which can be used in your application, to make it expose internal objects on some port for inspection. for.e.g. after i start my application in this case a GUI Application, and then say launch http://localhost:9100 then it should show me the statistics of the app. I played a bit with HttpListener accepting connec...

Help with debugging COM errors? (.mdi to .pdf file conversions using Microsoft Office Document Imaging)

I thought I had a working solution for converting .mdi files to PDF using the Microsoft Office Document Imaging object model. The solution is in a Windows Service, but now I'm running into some errors that I'm having trouble tracking down info on. The exception I get is: The server threw an exception. (Exception from HRESULT: 0x80...

Memory Card Information

I'm detecting the insertion of memory cards (removable media). Can I get information about the inserted media - type, manufacturer, etc? ...

Dotfuscator with a Web App

I have a situation where the client would like to have some minimal security for their source code. It is a web app and the host will be someone they will be partnering with. The worry is that it would be easy for the host to reverse engineer the code and setup shop on the side. I told them while it was not a real solution, obfuscatin...

SqlDateTime overflow Error on simple LINQ, C# .Net Web Page

I have a simple page I'm creating that just inserts some data from textboxes in .Net using C#. I get the overflow error stating the date must be within a specific range. The text being entered in the txtBirthdate box would be something like: 01/01/1980. When debugging, the Client1 _Birthdate object shows {1/1/1980 12:00:00}. So as far a...

How do I enumerate web part types in WSS site

Hi everyone, How would I go about enumerating the web part types available to be deployed to a web part page in a particular SPWeb by a user on a WSS 3.0 site? Sort of the equivalent of the list that you'd get via the "Add Web Part" link, but in a collection so that they could be instantiated and then added to a page. ...

Resources to read about Databinding causing memory leaks in WPF?

My wpf app is eating memory every time the ItemsSource of a TreeView is replaced (I simply construct a new object and assign it to the bound property). Furthermore the memory hoarding only occurs when I use a DataTemplate that is used in other ItemControls too. When I remove the DataTemplate the Treeview reverts to displaying the ToStri...

Looking for a wsdl-based scaffolding framework.

I am looking for a wsdl scaffolding framework, or even better if it was a POCO scaffolding framework. I need something like Dynamic Data, but running on wsdl metadata instead of db. I am currently using office infopath which generates decent forms based on wsdl, but I would like to have it in my app, and generated at runtime. Any ideas w...

Specify HTTPS for custom WCF Binding

I have an custom binding defined as follows: <customBinding> <binding name="binaryHttpBinding"> <binaryMessageEncoding /> <httpTransport /> </binding> This is used for an endpoint that a Silverlight 3 application uses to connect to the service. This works fine under HTTP, but i would like to specify this binding to use HTTPS and ...

Are there differences between running .NET app with 3.5 requirement on machine with or without SP1?

I have an application which requires 3.5 (not SP1.) My understanding is that SP1 is an additive service pack. Therefore, installing SP1 on a machine would not affect my application in any way besides performance. As far as I can tell from the sources listed below, SP1 is mostly about new features, and significant performance improveme...