.net

Why does System.Windows.Forms.HtmlDocument require full trust?

The HtmlDocument class has the following attribute: [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")] public sealed class HtmlDocument Why? Can I override this somehow? Or would i need to reflect the source and recompile? ...

How to configure Automapper to be injected with Ninject 2.0?

There are configuration examples for Structure Map and Windsor: http://www.cprieto.com/index.php/2009/08/20/using-automapper-with-castle-windsor/ But I haven't found anything for Ninject. Do you know how to translate those mappings to Ninject? ...

Handle in a console app

I have a console app in .net that I'm doing some processing of fonts. I'm using Win32APIs for this and one of them requires a device context for loading a font - actually a IntPtr hdc = GetDC(handle of screen element). Obviously, my app doesn't have these handles as it's a console app. Is there a way to get around this? ...

The type "x" is defined in an assembly that is not referenced. VS 2010 C#

Hi all, I am having a problem I just couldn't solve and would like some input. I am working with multiple class libraries in Visual Studio 2010, .net 4.0 Framework, in C#. I have a class library project which references the assembly output(.dll file) of another Visual Studio solution. The reference was added correctly to the class li...

How to Specify WebRequest IP to use (or HttpWebRequest if applicable) (C#)

Hi All, Is it possible to specify the IP address a WebRequest should use when creating a connection to a remote resource? For example, I have an MVC 2 website which runs on IP 0.0.0.10, but the server has 0.0.0.1 - 0.0.0.10 assigned to it. In the website there is a class that will be initialized based on user input and it will create re...

C# 4.0 Optional Parameters - How to Specify Optional Parameter of Type "Guid" ?

Hi Guys, Here's my method: public void SomeQuery(string email = "", Guid userId = Guid.Empty) { // do some query } userId is giving me an error as it must be a compile-time constant, which i understand. But even when i declare a const: private const emptyGuid = Guid.Empty; then change the method signature to: public void SomeQ...

What can WCF WebHttp do that ASP.NET MVC cannot?

Please, no "They solve 2 different problems" answers, it's the same HTTP request and response problem. Just because you have views/templates in MVC doesn't mean you have to use them. M_C is good enough for serving XML and JSON. Please, no "It's what Microsoft says you should do" answers. If I thought that way I wouldn't be asking this q...

ASP.NET Designer - How Do I generate this Design-Time Markup?

Hello, I want to generate this: <x:MyControl id="a" runat="server"> <Scripts> <x:MyScript .. /> </Scripts> </x:MyControl> I setup a control like: [ ParseChildren(true, "Scripts"), DefaultProperty("Scripts") ] public class MyControl: Control { [ PersistenceMode(PersistenceMode.InnerDefaultProperty), Mergabl...

Get ItemId of next email given ItemId of current email, using Exchange Web Services (EWS) Managed API

I need to write a method in C# that uses the Exchange Web Services (EWS) Managed API to read emails from a mailbox and given the ItemId/UniqueId of the current email, returns the ItemId/UniqueId of the next email in the inbox after the current email. Furthermore, for various reasons I require the method to be a static stateless method, ...

Server Push vs Client Pull for Agent-Server Topology

I need to create a system comprising of 2 components: A single server that process and stores data. It also periodically sends out updates to the agents Multiple agents that are installed at remote endpoints. These collect data in (often, but not always) long-running operations, and this data needs to get to the server I'm using C# ....

Paging/Sorting is not working inside <asp:UpdatePanel....

i am using LinqDataSource and a gridview control and my paging/sorting works fine but when i add <asp:UpdatePanel than its not working, below is my .aspx page and i am not sure what i am missing... <%@ Page Language="C#" MasterPageFile="~/MasterPage/MAIN.Master" AutoEventWireup="true" CodeBehind="ContPage.aspx.cs" Inherits="ContPage" %...

Securing MVC Rest + Soap Service with a single key strategy

I have an asp.net MVC 2 site setup to provide an API json/xml responses eg [GET] /Product/10 Returns an xml response of a product Additionally, I have a WCF SOAP service embedded into the site which returns the same methods (same contract) but via SOAP eg GetProduct(10) Returns an xml soap product. I chose this route because I li...

Does a Stream from a file contain the source file's attributes?

I'm trying to understand how File attributes such as the Created and Modified dates relate to a System.IO.Stream or System.IO.FileStream to the file. Are these attributes contained in the stream, or is the data part of the file that is read by the Stream separate from the file attributes? ...

How to write an NTLM Authentication Module?

I would need to write an Authentication Module for IIS7 that behaves exactly like NTLM, but does some extra checking. The Module does NTLM against Active Directory (so that the module knows if the user is OK) and then needs to call another service to finally verify access. I have to do this in an Authentication Module because the actual...

Use reflection to determine which base class constructor is called

// Using reflection on the type DerivedClassB // can we determine: // a) that it uses the base class ctor that takes a string param // b) the actual value that it passes? public class BaseClass { public BaseClass() { } public BaseClass(string someParameter) { } } public class DerivedClas...

vb.net - performance implications of implementing a generic type and a delegate in a function

I wrote a serializer (to Byte Array) for dictionaries that have a string key, but an object of some sort as its value. I've never implemented a generic type in a function or used a delegate before, so I'm a bit concerned about this being significantly slower than writing a serialization function for a specific type of Dictionary (Dictio...

Avoid the carriage return when writing InnerText in xml elements using System.Xml.XmlWriter

Hi everyone, I'm using XmlWriter to save an XmlDocument in .Net. However all the elements that have InnerText are written with surrounding carriage return characters. I tried using XmlWriterSettings to avoid the writing of those characters, but no luck yet. Here it is a piece of code used: XmlDocument outXml = new XmlDocument...

Creating Instances of IronPython Classes From C#

I want to create an instance of an IronPython class from C#, but my current attempts all seem to have failed. This is my current code: ConstructorInfo[] ci = type.GetConstructors(); foreach (ConstructorInfo t in from t in ci where t.GetParameters().Length == 1 select t) { ...

Simulating Screen capturing as a webcam?

Do we have a way to simulate a webcam driver, that will provide realtime captured screen (30 frames per sec) as it's output? ...

Portable .Net debugging tools...

As a .net developer there are times when one is asked to debug at different machines (32 & 64 bit) other than ones own developer machine. Lot of times some important tool is missing and I have to install them first to start the debugging. Then I started to collect some portable tools in a 1GB memory stick. Currently it contains Windbg ...