.net

Check if URL is a torrent in C# .NET

Hi! What's the best way for me to take url like: http://foobar.com/foo.torrent and check if that really is a torrent, not a html page or something else funny. Suggestions? Thank you :) ...

DeleteSubKey UnauthorizedAccessException

I'm trying to write a quick app to modify some registry keys. When I'm browsing via RegEdit, I can modify and delete the keys with no problems. But when I try to use RegistryKey.DeleteSubKey() it throws an UnauthorizedAccessException Is there anyway to gain the privileges to do this? Also, why would there be a problem if my user acco...

Hardware Emulator / Simulator for Winforms .Net Application

I have a WinForms .Net HMI software which talks to hardware over USB. I check for communication with the hardware at Load time and if communication is active then run it (The hardware manufacturer has provided a communication library to talk over USB). I want to build an emulator for cases when communication with hardware is not possib...

ASP.NET and IsNew on the page level

Never seen this before in ASP.NET development. I'm trying to refactor out 40 single-page ASP.NET pages to code-behind style. What does this code do? // Validate required parameters (if "new", then nothing is required) if (!this.IsNew()) { if (string.IsNullOrEmpty(_billId)) { responseErrorNo = 4; Utils.SendError(respErrNum);...

How to translate legacy (OLE) colors to (A)RGB with .NET?

I have a list of color values encoded as signed integers (OLE I think) in a legacy INI file that I need to translate into (A)RGB values with .NET. An INI example: [INI_Section] Color=-2147483633 Doing something like: Color.FromArgb(-2147483633) gives an alpha-blended version of a color that is not at all what I expect. I think t...

In-Proc SxS opens for shell extension in managed code?

The recommendation used to be "Do not write in-process shell extensions in managed code." But with .NET Framework 4 and In-Process Side-by-Side the main reason not to write shell extensions in managed code should be resolved. With that said, I have three questions. Is it now okay to write shell extensions in managed code? Which probl...

Is it possible to protect a single element in the appSettings section instead of the entire section?

I would like to protect one key/value pair in my appSettings but not the others using something like I've previously done with the ProtectSection method as seen below. var configurationSection = config.GetSection("appSettings"); configurationSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); Ideally I ...

.net printing multiple reports in one document (architecture question)

I understand how to print a single document via the PrintDocument class. However, I want to print multiple reports in one document. Each "report" will consist of charts, tables, etc. I want to have two reports per page. I've studied the few examples I can find on how to combine multiple documents into one; however, they always seem t...

Pattern for GUI applet for sound control

Writing a sound control applet with GUI that communicates with a device via USB. There are several type of controls being used, faders, knobs, on/off switches. Although there are functional similarites there are often different calcualtions, ranges and settings for each, though ultimately everything gets funneled into a big structure and...

Can I disable window autoplay function programatically with C#/.NET?

Does anybody know a way to deactivate the autoplay function of windows using c#/.NET? ...

Invoking another URL

string url = "http://foo.com/bar?id=" + id + "&more=" + more; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); I m trying make a call to another server, and getting back the following: |FATAL|The remote server returned an error: (406) Not A...

Sending a Tuple object over WCF?

Is the System.Tuple class supported by WCF's Data Contract Serializer (i.e., can I pass Tuple objects to WCF calls and/or receive them as part or all of the result)? I found this page, but not the clear, definitive "you can send and receive Tuples with WCF" answer I was hoping for. I'm guessing that you can, as long as all of the type...

32 and 64 bit assemblies in one windows installer

Hello, I have an application written in C# which depends on sqlite managed provider. The sqlite provider is platform dependent (there are two dlls for 32 and 64 bit applications with the same name). The application loads the desired one at runtime based on OS. The problem is that while creating an installer I cannot add 64 bit mode dll...

How to disable ILASM warnings

Hi. Does anybody knows if there is a way to tell ilasm to completely ignore warnings when compiling an il file?? I know it is possible somehow, by inserting "something" inside the il code. But what? A ilasm command line parameter would come in handy too Thanks! ...

Is learning WinForms worthwhile? Is it outdated?

I just completed two WinForm applications as part of an intensive course. Just wondering about the technology overall... should I move onto something new, or is WinForms still viable for the future? ...

How to marshal int* in C#?

Hi, I would like to call this method in unmanaged library: void __stdcall GetConstraints( unsigned int* puiMaxWidth, unsigned int* puiMaxHeight, unsigned int* puiMaxBoxes ); My solution: Delegate definition: [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void GetConstraintsDel(UIntPtr puiMaxWidth,...

Is there anything available for .NET to get the differences in two strings?

I'm looking for a way to determine the differences between two strings, and highlight them in both strings. I would suspect that most 'diff' libraries won't work since they show differences in lines (I believe). Either an algorithm or library will work. Thanks, Mark ...

UI not redrawing after display powered off on Win 7

Some portions of my application's interface are not getting refreshed after Windows 7 powers down the display. More specifically, I'm swapping out images, User Controls, and a button's content while the display is powered off and after it has been restarted, and this isn't being reflected in the UI until I minimize and restore the window...

ASP.NET Repeater datasource bound to a function. Would it call the function twice?

In the code behind I have a function that returns a List(Of SomeClass): rptRepeater.DataSource = SomeFunction(SomeVariable) rptRepeater.DataBind() In the html I have a basic repeater layout and am using the below code to get the Properties of each object returned. <%#Databinder.Eval(Container.DataItem, "Parameter1")%> My question is...

FileInfo.MoveTo() vs File.Move()

Is there any difference between these two methods of moving a file? System.IO.FileInfo f = new System.IO.FileInfo(@"c:\foo.txt"); f.MoveTo(@"c:\bar.txt"); //vs System.IO.File.Move(@"c:\foo.txt", @"c:\bar.txt"); ...