.net

What resources explain Reflection and Meta Programming in C#?

I've been programming in C# for a while now and would say I can use it and the .Net library fairly well. One huge gap in my knowledge though is how to use Reflection and Meta Programming with .Net/C#. Can someone point me to some good resources on the subject and how to get started with it? ...

Add Items to Windows Context Menu

Hi! I am writing an app and I was wondering how could you add something to the windows context-menu (when you right click on the windows exspor) like in 7Zip or winRAR to preform certain actions i.e. encrypt file\zip file; in vb.net, or perhaps is there a way in the windows installer template? I don't really want to use the shell method...

F# vs IronPython: When is one preferred to the other?

While the languages F# and IronPython are technically dissimilar, there is large overlap between their potential uses in my opinion. When is one more applicable than the other? So far it look to me like F# is computationally more efficient while IronPython inherits a better library from Python. I am happy to be corrected. There is a so...

How to get ObjectSet<T>'s entity key name?

I've created a generic ObjectSet<T> in my generic repository. What I would like to get is the name of the EntityKey of ObjectSet<T> so that I can use it in the DataContext.GetObjectByKey. I've searched around and dug deep, but I can't seem to find this value anywhere in the ObjectSet class. ...

BackgroundWorker questions.

I have UI WPF application. May by some one have any ideas why this code is not working? Case 1: BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { //some logic }; worker.RunWorkerAsync(); In that case i am getting exception The calling thread cannot access this object because a different thread owns i...

Simple Regular expression question.

Hi, I have a large malformed test HTML document which I need to get the numbers out of: I'd like to get the primary ratio out. I'm using this regular expression: (?<=Primary ratio</TD><TD>--</TD><TD>).*(?=</TD>) On this string: Primary ratio</TD><TD>--</TD><TD>10.52</TD><TD>14.97</TD><TD></TD></TR><TR align='right'><TD align='left'>...

Managed + unmanaged application causes memory leak

I have a wrapper managed application(.net) over a COM Component(created using vb6) where Com component also uses native c++ dll. Aplication runs as a background process and is supposed to run continously 24 X 7. The application runs fine for certain time, but after certain time it crashes. Possible reasons might be momory leak in c++ d...

Extending primitive types

Is it possible to extend primitive types such as System.String and System.Int32 (IE: integer) in .Net 4 and if so how? To be more specific, I am aware of the concept of partial classes but this doesnt seem to be the answer. Also I find that System.String is not inheritable and Int32 is a structure. Lastly I am interested in knowing bot...

How to play a file in Silverlight Media Framework locally?

I am using Silverlight Media Framework in one of my project. Now i want to play a media file in the browser, the media file is in my D drive of PC? I code in XAML to play the file but the SMF player is not getting the media source. The code of XAML that am using to access the file is following. <Core:SMFPlayer> <Core:SMFPlayer....

Why don't we use new operator while initializing a string ?

I was asked this question in an interview: Is string a reference type or a value type. I said its a reference type. Then he asked me why don't we use new operator while initializing the string ? I said because the c# language has a simpler syntax for creating a string and the compiler automatically converts the code into a call for the...

Partially change a WPF template for a standard control

I have a TextBox control placed inside my window and I would like to change its Border. In order to do this, I have to somehow modify the existing Border set by the default control template. Is there a way to modify only a part of a default control template (for a standard WPF control) by somehow overriding the existing objects? ...

Looking for a .NET Configuration Framework

Due to my next project (much SOA stuff) I need a component based configuration and stored in a database to enable a central administration. app.config/web.config does not support any of those requirements (I know some hacks with app-domains, though). So does anybody of you know a configuration framework? It does not necessary have to be ...

Get local computer name via Citrix session in .NET

I need to get the local Computer Name for a desktop computer running our software application through a Citrix session. When I query My.Computer.Name I get the name of the server. How can I get the name of the actual physical computer that the session is running on, and is there there an event I can monitor for when someone switches a s...

Is there any reason not to use Run-time Contract Checking with Code Contracts?

I've recently listened to Kevin Hazzard talk about Code Contracts in .Net Rocks show 570 (http://devjourney.com/community/dotnet-rocks-show-570-with-kevin-hazzard/). He mentions enabling Run-time Contract Checking as an option some people might choose to use while others might not. Why would you not use Run-time Contract Checking for yo...

Why does adding a service reference generate the same class twice

I'm trying to create a simple RESTful interface to my data. I've created a WCF web service and decided to use LINQ to SQL to connect to the database. Instead of making simple pass through objects, I decided to try just serializing the objects created by my LINQ to SQL dbml. I changed the Serialization Mode of the dbml to Unidirectional t...

Silverlight: how to handle standard assemblies

A usual Silverlight task: to make the size of xap-file smaller. There are a lot of hot-to-do manuals that explain how to make your application modular. But I didn't find anyone that explains how to make "modular" standard libraries. The biggest part of my xap-file (1.7Mb, when overall size is 1.8Mb) is occupied by standard assemblies: a...

Working with URL query Strings in ASP.NET

I am new to working with ASP.NET and want to find the best way to work with URL query strings. I can get the current value of a URL query string by using Request.QueryString["UrlKey"], but can I actually modify the URL with code, without doing a form GET submission? If the user is landing on the page for the first time, what is the eas...

Silverlight 4 HttpWebRequest throwing ProtocolViolationException

I'm invoking a REST service via http which returns a stream as the response. My client code looks like so: Uri uri = new Uri(remoteAddress); var webRequest = (HttpWebRequest)WebRequest.Create(uri); webRequest.Method = "GET"; webRequest.ContentType = "multipart/mixed"; ...

Why does EndGetResponse throw ArgumentNullException?

The following line of code throws an ArgumentNullException under Chrome and Firefox in silverlight. I am using HttpWebRequest to post a file to the server. The exception doesn't happen in IE and only happens when I am uploading a larger file (5mb). Under IE it works just fine. I didn't see any reason in the documentation why the code...

Console-like text control?

I'm looking for a winforms control that can output text like in a console window (output is appended to the bottom, color formatting, etc.) Much like the "output" window in most IDEs. I tried making one myself but it didn't work the way I wanted, so I'm wondering if there is some existing control out there. This is for an open-source p...