.net

Best practice for authorization in the business layer?

What is the best way (for a .Net 4 project) to implement authorization in the business layer. Simply I want to check whether a certain identity can access a certain action/resource. I've tried to look this up in Patterns & Practices, but haven't found anything useful yet. And what about PrincipalPermission of ASP.Net 2.0? Is this still...

Retrieving file extension from a file when it doesn't exist in the filename (in C#)?

I tried searching for this but my Google has failed me. I have a directory full of files that are just their GUID: b3445ffb-55f4-4538-bc6f-13534fd549f6 I know they can be only a handful of file extensions (doc,docx,pdf,jpg), but obviously the file extension does not exist. I could write a script that simply tries to open the file usin...

"Formatter" and "Serializer" - any difference between the terms?

Some things in .NET are called "formatters" - BinaryFormatter, SoapFormatter. Others are called "serializers" - XmlSerializer, DataContractSerializer. Why the difference? ...

wpf image viewer path

I would like to make an image viewer where the client can load thumbnails to a file, then when the Photo Gallery button is selected the thumbnails appear in a grid and when the thumbnail is selected a larger photo will show in a viwbox. How do I get the path for the button click event to the photos? Can this be done in a markup ext? ...

How to check the arguments with Regex?

I'm stuck with regular expressions. The program is a console application written in C#. There are a few commands. I want to check the arguments are right first. I thought it'll be easy with Regex but couldn't do that: var strArgs = ""; foreach (var x in args) { strArgs += x + " "; } if (!Regex.IsMatch(strArgs, @"(-\?|-help|-c|-cont...

Limit DoD PKI Certificate Selection

Is there a way to limit the certificates listed in the dialog box when prompted for DoD PKI authentication? I'm trying to require the user to choose the email certificate. ...

xsl foreach loop not working on xml

I've been trying to iterate through an XML file using XSL , however I'm having major troubles as the only first language is being recognised. Help! <?xml version="1.0"?> <languages count="1"> <language>English (UK)</language> <language>Spanish</language> <language>Arabic</language> </languages> <xsl:stylesheet xmlns:xsl="http://...

WCF generated proxy does not contain *Specified property flags for WSDL string fields with minoccurs="0"

I've noticed that the WCF proxy generator is not generating the "specified" property flags for string fields EG When I have two fields on a complexType specified in the WSDL: <xs:element name="testStringField" type="xs:string" minOccurs="0" /> <xs:element name="testDecimalField" type="xs:decimal" minOccurs="0" /> the proxy generato...

View xml request in SOAP call

I'm trying to debug some problems we have with a web service, and would like to view the xml used in the SOAP call. Anyone who know how I can do this in visual studio 2008? I'm developing on windows mobile 6 using compact framework 3.5... ...

Change Zindex via xaml

Is it possible to update the zindex property of an element via a trigger in the xaml? I thought something like below would work, but it's not: <i:EventTrigger EventName="MouseEnter"> <ei:ChangePropertyAction TargetObject="{Binding ElementName=Grid}" PropertyName="Canvas.ZIndex" Value="999"/> </i:EventTrigger> thanks, voss. ...

How do I attach my Visual Stuido Add-in window to a tab programmatically?

I'm creating a small addin in the hopes of making it fun and easy to play with graphics in Visual Studio. There has been one small annoyance though, I can't seem to figure out how to attach my newly created window to the tab bar. It's all F#, but the solution should be just a couple of function calls so please feel free to use C# or VB...

Prevent component from opening a pop-up window in own .NET application

In my application, I have a component, which opens a pop-up window (save dialog). There's no legitimate method for disabling that dialog. Killing it by timer is not reliable way. Is there any accurate way for preventing the dialog from opening? ...

Patching after ILMerge

We're looking into using ILMerge (along with NGEN.exe and GAC registration) to improve the startup times of our application. It looks like we won't be able to merge all of the assemblies into one dll because it will prevent any patching of our application post-deployment. We've been using msimsp.exe to generate a patch which just repla...

Is there an event for when garbage collection occurs in .NET?

I've got a weird slowdown in my ASP.NET website that I cannot seem to track down. I'm suspecting that GC might be kicking in and halting my threads. To know for sure it would be nice to log every time when GC does occur. I could make a dummy object and do the logging in its finalizer, but that would then be a one-shot solution, while in...

What is the difference in intent between the serializers in FCL?

This question does a good job of explaining the difference in functionality between the serializers. BinaryFormatter is fast, XmlSerializer is interoperable, etc. I know that. But what is the difference in intent? What use-case was each class designed for? In particular: Why did they decide to make XmlSerializer blind for private dat...

How do I change the auto generated wsdl that a soap service generates in .net

I am trying to mock up a java web service that isn't complete but has been designed, i.e. I have the wsdl. I've implemented a .net web service with the classes and methods required with the same names, etc. However when I request the wsdl from the .net web service, the proxy classes generated contain the suffix "Soap", .e.g instead of ...

Handle .NET DataGridViewCheckBox Changed Event

How can I handle aCheckedChanged event for a cell in a DataGridViewCheckBoxColumn? Note: If applicable, I prefer VB.NET answers over C#, but I'll accept either. ...

Using Win32 libraries through Windows Form elements

I have created a simple GUI using Windows Forms in visual C++ 2008. There is a button in the GUI. When the button is pressed I want mouse cursor to point at coordinates (0,900). I have created separate header and c++ source file that sets the cursor position to specified location (x,y). For this I have used Win32's SetCursorPos() functio...

Does Microsoft Windows SDK for Windows 7 include library for MS unit testing?

After I installed the SDK on our new Windows 7 build machine, I got errors from our unit test project: DsHelperTest.cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) SKMTest.cs(3,17): error CS0234: The type or namespace name 'VisualStudi...

Request.ServerVariables("REMOTE_ADDR") retrieving the same IP for multiple logins inside and outside my company

I've been asked to write code to track IP addresses of visitors to one of my company's online applications in .NET. This is actually the second one I've done, having done another site late last year. I noticed then, and again now, that I sometimes get the same IP address showing up for what I know is another box.....sometimes a co-work...