.net

Requested registry access is not allowed

I'm writing a tweak utility that modifies some keys under HKEY_CLASSES_ROOT. All works fine under Windows XP and so on. But I'm getting error Requested registry access is not allowed under Windows 7. Vista and 2008 I guess too. How should I modify my code to add UAC support? ...

How to change file association without UAC confirmation?

When I was working with file association in a .NET application I hadn't had found a way to set it without UAC popping up a confirmation dialog. Today, when I opened uTorrent and looked up for file association, I've found that you can enable (writing to registry) without any confirmation from the UAC. How is that possible? uTorrent is n...

Subclassing ViewPage to share common ViewData: Is it dumb?

I'm setting up a wizard. All of my wizard views need access to common data for display like TotalWizardSteps and CurrentWizardStep. I'm trying to find the best way to go about adding this common data to the ViewDataDictionary. I'm thinking of creating my own WizardStepViewPage. This subclass would have a property 'WizardData' which retur...

Coerce types in different namespaces with Identical layout in C#

I've started writing an interface for FedEx's webservice APIs. They have 3 different APIs that I'm interested in; Rate, Ship, and Track. I am generating the service proxies with SvcUtil.exe. The different service endpoints are each specified by FedEx in their own WSDL files. Each service endpoint has it's own xml namespace (e.g. http...

Protocol Buffers In C#: How Are Boxed Value Types Handled

In the following examples: public class RowData { public object[] Values; } public class FieldData { public object Value; } I am curious as how either protobuf-net or dotnet-protobufs would handle such classes. I am more familiar with protobuf-net, so what I actually have is: [ProtoContract] public class RowData { [Prot...

ASP.NET MVC missing htmlhelpers

I keep reading about html helpers for images and a lot of other useful controls. The problem is I only get a few in the intellisense. I only get about 18 and they all seem form orientated (radionbutton, dropdownlist, beginform, etc) My web.config has the folowing: <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=ne...

Add users to a Security Group in active directory

Using any .NET framework I am able to create security groups, however when I try to add users from within the same domain I get an error. Using System.DirectoryServices.AccountManagement: TheGroup = GroupPrincipal.FindByIdentity(SecurityContext, "GROUPNAME") TheGroup.Members.Add(SecurityContext, IdentityType.SamAccountName, "username"...

C# .net How to display a message in the output window without being in debug mode ?

I'm from Java background, in Java program I can use System.out.println(message) to print a message to the output window, what's the equivalent in the C# .net Visual Studio ? I know when I'm in debug mode I can use : Debug.WriteLine("Debug : User_Id = "+Session["User_Id"]);<Br> System.Diagnostics.Trace.WriteLine("Debug : User_Id = "+Ses...

How will a lock respond to a race condition?

How long will a thread wait for a race condition in the following scenario? A file is added to a collection: lock(mylock) { // add to collection } It is then removed from the collection in a similiar manner. If a thread is trying to add to the collection while the service is removing it from the collection, who wins? Or is...

What advantages are there to developing a Win32 app in C++ over a .NET app in C#?

I learned windows programming using Visual C++, and the Win32 API. Nowadays, it seems most apps are being developed in .NET using C#. I understand that most of the time there isn't much performance difference between native code and managed code. So I'm wondering, if I were to start writing a new desktop app today, is there any reason (o...

Can the "this" keyword be used with value types?

I noticed this interesting use of the "this" keyword while viewing the disassembled code of Int32.GetHashCode() in .NET Reflector: public override int GetHashCode() { return this; } I always thought "this" is only used with reference types not value types. In the code above, will boxing be used every time you try to get the hash c...

How to require x86 up the .NET dependency chain when building

We have several projects that use p4.net, a managed DLL, which in turn is dependent on p4dn.dll, a 32-bit unmanaged DLL. This has problems on x64 systems, so I have had to go to each project that uses p4.net and set its processor type to x86. If I understand the problem right, it's that when .NET loads an exe, it checks for a manifest a...

GAC behaviour

I put signed dll into GAC. I delete this dll from folder where other applications could reach it. I try to run client app, which used that dll. Dll is immidiately put back to the original folder. How does it happen? I am guessing that GAC is monitoring folder and when it detects that dll is missing it puts the latest version back to the...

How do I override the error message on a databound control in WinForms?

I have a form in my application that uses a binding source to bind the controls to a model object. This works, and handles basic validation such as ensuring that the user doesn't enter text into a numeric field, for example. I am using an ErrorProvider, and setting its datasource = the binding source in order to display the error messag...

Where can I find a good NHibernate and ASP.NET MVC Reference Application

Where can I find a good NHibernate and ASP.NET MVC Reference Application? I downloaded S#arp and this seemed to be a lot more than I needed (IOC and CodeGen via T4). I might work my way up to this later, but I need something smaller at first. Any simple examples? I just want to pick up how NHibernate Session handling works in ASP.NET MV...

How we run .NET 32bit Application in a 64bit Windows Server?

We are installing a third party application in one of our 64bit windows servers. This application apparently was build with the compiler option set to choose the platform at run time. When we run the application it gives us a System.BadImageFormatException: is not a valid Win32 application. Errrors. I have seen in forums from the ...

How can I resolve a "Provider load failure" for WMI requests?

I'm using WMI to collect system information. It works fine on every system I've tested it on, but I have one or two users that are reporting problems. The debug logs show the WMI code is throwing a "Provider load failure" exception. I haven't been able to replicate the issue. The users have verified that the WMI service is running in...

Good Quality Free Gridview for .NET WinForms

Is there a good quality free Gridview for .NET WinForms? The Xceed datagrid (express edition) is lovely, but is for WPF. It's nice and simple, isn't overwhelming in the features department, and looks great at the click of a button. I'm looking for something similar for WinForms. ...

Stopping an Async HttpWebRequest

I have an application that makes several concurrent requests to a web resource using HttpWebRequest asynchronously. Even though I've set the timeout property of my HttpWebRequest instance to say 5 seconds, sometimes when async calling BeginGetRequestStream, getting the stream can take much longer than that and is causing quote a mess for...

Reverse a ResourceManager

If you do ResourceManager.GetString(Key), you can get the value of an item in a resource. Is there a way to do a reverse lookup to get the key from the resource given the value (essentially de-translate)? ...