.net

ReSharper - var hint only for none basic type

I like the fact that ReSharper suggest me to use the var keyword. Instead, I would like to know if it is possible to ReSharper to only hints me when I use type that are not basic. Example :int myInt = ..., string myString = .... No hint here I prefer to use var on complex type like : var myHttpModule = ..., var userRepository = ... ...

What does it mean in Visual Studio debugger value "{ }" ?

Hi all, I have in my Visual Studio 2008 .NET C# project one property observed and debugger shows open and immediately closed curly brackets "{}". I believe it is uninitialized (I)List, but why it does not shows "null" or "unitialized". What does "{}" it means ? br, Milan. ...

How to catch exception when loading .NET WinForm app user.config file?

Sometimes in .NET (2.0) WinForm desktop apps which use the default configuration system, the user.config file will become corrupted and can't be loaded anymore (when the configuration system tries to load it, it'll throw a System.Xml.XmlException). Putting aside the question of "why did the file get corrupted in the first place" (maybe ...

Adding viewstate to new instance of page (.Net)

Hello, I develop an Aspx-page and when some control on the page is triggered, I want to redirect the browser to a new instance of the page, adding some url-parameters. But I also would like to restore possible changes, which the user might have made between first visiting the page and clicking on the control which caused the Response.R...

WCF : Is it possible to move all service settings outside the config file, and in the code?

I have a WCF that is in use now for over a year, coded by someone else and i'm trying to refactor it but the way the folder structure is organized and the svc.cs file containing the methods is not what I am used to from WCF samples I completed. Here is what I'm trying to achieve. Since none of the settings changed over the last year I a...

Multi-level interface inheritance with .NET and COM Interop

This question is a follow-up to my last question with a reference to COM Interop. Let's say I have the following 2 interfaces and implementing classes: public interface ISkuItem { public string SKU { get; set; } } public interface ICartItem : ISkuItem { public int Quantity { get; set; } public bool IsDiscountable { ...

External Connector Licensing with website hosted on windows

I we have created a website that requires users to login. It used forms based authentication and sql server to validation the login credentials. Should we need to purchase an external connector license from microsoft to be able to host this site on a windows .net platform. Edit: More information about external connectors. In microsoft ...

FilterExpression on SQLDataSource in c#

What does the FilterExpression do on a SQLDataSource in C#? ...

Capture screenshot Including Semitransparent windows in .NET

I would like a relatively hack-free way to do this, any ideas? For example, the following takes a screenshot that doesn't include the semi-transparent window: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown Text = "Opaque Window" Dim win2 As N...

ScriptModule breaking my .net project from running

when i take out the chunk from my web.config my project works fine. with it my project doesnt even load in a browser. with this part in my config i get a unhelpfull Runtime Error telling me to turn on debugging... but in my config it is on!!! <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.W...

MVVM Practice for accessing the entire view.

Still a bit new to the concept of M-V-VM in WPF, here's my problem: I've built up my ui pretty cleanly, I have the following: CareersView.xaml - View CareersView.xaml.cs - View (Code Behind) CareersViewModel.cs - View-Model Career - Model The View-Model is all wired up through bindings and cleanly keeps all logic inside it for testa...

URL Encode all non alpha numeric in C#

I need to fully URL Encode an email address. HttpUtility.UrlEncode seems to ignore certain characters such as ! and . I need to pass an email address in a url formated like this: /Users/[email protected]/Comments Because my WebMethod uri template looks like this: [WebGet(UriTemplate = "Users/{emailAddress}/Comments")] The period bre...

Viewing a TIFF stream using the .NET webbrowser control in C# doesn't show image...

I have a windows form that is using a Webbrowser control to view documents on a web server. When it tries to display a TIFF, it just displays a blank screen. It works with other file types just fine. The URL to the TIFF works fine if I paste it into Firefox. Will this flat out not work, am I doing something wrong? Should I invest in a...

.NET NamedPipeServerStream problem - consecutive Reads return the same data

I'm having a problem with NamedPipeServerStream - when my code reads data it's just repeating the output of the last Read without grabbing the new data. Here's the smallest server code example that exhibits this behaviour: using System; using System.IO; using System.IO.Pipes; using System.Text; namespace ConsoleApplication1 { clas...

Will this DateTime optimization cause localization problems? Will it be more efficient? Is it worth it?

I'm working on updating a project which uses the following code to place a file in a folder based on the date: int month = DateTime.Now.Month; string zero = (month < 10) ? "-0" : "-"; string folder = "Folder" + DateTime.Now.Year.ToString() + zero + month.ToString() + "\\"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(fo...

how to get object that triggered constraint violation in entity framework

Hi everyone. Here is the situation: Lets's imagine we have table A in the database and we've created Entity model for that table. Let's also imagine that there are several Uniqeu and Foreign constraints in that table. Now let's do the following: load more than 1 record from that table into the context. Change some objects to make som...

Releasing .NET objects from VB6 code

On .NET Rocks! Show 561, Carl and Richard talked about releasing unmanaged objects instantiated in managed code. If you have to release a COM object that's instantiated in managed .NET code, you have to call System.Runtime.InteropServices.Marshall.ReleaseComObject. Is there anything similar you have to do (or should do) when releasing ...

How to call GetGUIThreadInfo in c#

I have a window handle and am trying to call GetGUIThreadInfo by passing in the window's process id. I am always getting an error "Parameter incorrect" on the call to GetGUIThreadInfo and I can figure out why. Has anyone got this to work? [DllImport("user32.dll", SetLastError = true)] public static extern bool GetGUIThreadInfo(unit hT...

Code Contracts Static Analysis: Prover Limitations?

I've been playing with Code Contracts and I really like what I've seen so far. They encourage me to evaluate and explicitly declare my assumptions, which has already helped me to identify a few corner cases I hadn't considered in the code to which I'm adding contracts. Right now I'm playing with trying to enforce more sophisticated inv...

SQL Server and TransactionScope (with MSDTC): Sporadically can't get connection

I've written some tests for .net code that invokes calls to my SQL Server. It appears that using System.Transactions is an excellent choice for rolling back any modifications to the database that result. I'm aware that some purists would suggest that I might want to mock the database, but I'm not going down that road; this is not stric...