.net

How do I close a window using a button (window.close() doesnt work)?

I open a new window and would like to give the user the option of closing the window using a button. I thought window.close() would work, but nothing happens. Below is a copy of my code. <script type="text/javascript" language="javascript"> function CloseWindow() { //window.open('', '_self', ''); window.close(); } </script> .....

Help Rendering ASP.NET MVC View from a Console App

I have created an ASP.NET MVC View. On my MVC WebApp, it works great. I would like to be able to (from a console app) render the View out as an HTML Email. I'm wondering what the best way to do this is going to be, the part I'm struggling with is Rendering the View. Is there any way to do this from a console application? The webapp ...

Lazy loading a subclass from a POCO in Entity Framework 4.0

I was wondering if anyone has attempted to lazy load a subclass (where is isn't known what the subclass is until the result is returned) using EF and POCOs? This is a bit of a nightmare in NHibernate, but works as long as you don't attempt to cast the returned result to a subclass (because a proxy of the base class is created, it can't ...

Play media to device using existing WMP libraries.

LS, I was looking through the different Windows Media Player libraries (COM), but couldn't find a way to stream a media file to an external device or tell the device to start playing a certain file from a certain location. If there is an easier way not involving WMP I would be glad to take/investigate that path as well! Kind regards, ...

Why is streamreader hooked up to networkstream returning null on ReadLine()?

In the code below I have a StreamReader reading from a network stream. This code normally will run fine for days. I ran into a problem where all of a sudden StreamReader.ReadLine() started returning null. According to Microsoft documentation StreamReader.ReadLine() will return null when it has reached the end of the input stream. This d...

how was Array.Sort implemented in .NET?

I am using structures in my programming and I sort the structure according to a value in the structure using IComparer. How did Microsoft implement the Array.Sort() method? Is there any documentation (references) for this? Is it the same for all types of Sort() in Visual Basic? This is a simple example for what I want. Dim MyArray(6...

JSON.NET: Deserializing part of a JSON object to a dictionary

I have JSON like this: { "Property":"Blah blah", "Dictionary": { "Key1" : "Value1", "Key2" : "Value2", "Key3" : "Value3" } } I want to extract the "Dictionary" object as a Dictionary (so it'd be like Key1 => Value1, etc.). If I just had the "Dictionary" object directly, I could use: JsonConvert.Dese...

File.Copy does not overwrite file

Hi I want File.Copy(filePath, newPath); to overwrite file file if it exists. Currenly it throws IOException. ...

When using SQLite what do I have to have in end users machines?

This program will run 100% independently from anyone. Just the guy and his computer. The SQLite database is just a little .db file right? I've also downloaded a driver for accessing the SQLite database using Entity Framework. What would I need to deploy on a users machine? Just the folder with the .exe and the .db file? Thanks. ...

Windows installer calling .Net3.5 to execute a .Net 4 assembly

I have an App I have updated with some .Net4 assemblies, including the custom actions .dll that runs when the app is going to be uninstalled. The App was initially installed with .Net 3.5 and it requires some custom actions when installing and uninstalling. The problem is that now when uninstalling the .dll of the custom actions have ch...

Extract keywords from text in .NET

I need to calculate how many times each keyword is reoccurring in a string, with sorting by highest number. What's the fastest algorithm available in .NET code for this purpose? ...

Is there a way to examine WebResponse without affecting the underlying response stream in .NET?

After a call to initial HttpWebResponse.GetResponseStream() and reading through the stream, that stream is done for and cannot be reused. I have a situation where I need to examine the content of the response and if it is of a certain data, get another page and then pass the new response down the line. Otherwise, pass down the original...

How do I pass an Array (By Reference, in VB6) to a C\C++ *.dll subroutine?

I need to pass an empty Array of Variants to a DLL written in C (and available on all Windows versions), and the C code (which I have no control over and cannot edit) will populate the Empty Array of Variants with its some return values. Bascially, when I try this - the ByRef Array is always empty when it should contain the results of t...

GetMethod for generic method

I'm trying to retrieve MethodInfo for Where method of Enumerable type: typeof (Enumerable).GetMethod("Where", new Type[] { typeof(IEnumerable<>), typeof(Func<,>) }) but get null. What am I doing wrong? ...

C#: Deserializing JSON primitives into .NET complex types

I have a file named config.json. Here's its contents: { dataSources: [ "http://www.blahblah.com/blah", "http://www.blahblah.com/blah2", ... ], skills: [ { "name": "foobaris", "regex": "pattern" }, ... ] } I want to create a Config object o...

Is it bad to declare a page variables in ASP.NET?

Not sure if "page variable" is the right word, but i'm thinking something like this: using System; . . . namespace whatever { public partial class Submit : Page { int id; protected void Page_Load() { id = getid(); } . . . Obviously I will be using id at some point later (not in PageLoad)....

Is there any application by Microsoft targeting the end user market and running on the .NET framework?

It's all in the title. Inspired by http://www.reddit.com/r/programming/comments/dx8au/lessons_from_evernotes_flight_from_net/ Edit: I am primarily thinking about desktop apps, not web apps. ...

Does Task.Wait(int) stop the task if the timeout elapses without the task finishing?

I have a task and I expect it to take under a second to run but if it takes longer than a few seconds I want to cancel the task. For example: Task t = new Task(() => { while (true) { Thread.Sleep(500); } }); t.Start(); t.Wait(3000); Notice that after 3000 milliseco...

Creating end-user documentation - What tools exist in .NET?

I should preface this by saying that this post should almost surely be a community wiki, though I don't know how to set that up. If someone could change this I would really appreciate it. We're working on a product that is a web-based application. We'd like to get some conceptual user documentation integrated into the app, preferably ...

Read Flash Cookie from javascript or ASP.Net

We have a flash video that was created for our project, we dont the source so we have to work around the compiled flash file. We are going to host the video on our domain and the video creates a sol cookie (flash cookie) file to store how far the user has proceeded though the video. So my plan is to access this cookie to see how far th...