.net

The mystery of the twin exceptions

Here's an interesting question. I have a system that attempts to run some initialization code. If it fails, we call the deinitializer to clean everything up. Because we call the deinitializer in exception handling, we run the risk that both initialize and deinitialize will fail, and hypothetically, it now seems that we have to throw two...

Character encoding problem - PHP output, read by .NET, via HttpWebRequest

I have a PHP script (running on a Linux server) that ouputs the names of some files on the server. It outputs these file names in a simple text-only format. This output is read from a VB.NET program by using HttpWebRequest, HttpWebResponse, and a StreamReader. The problem is that some of the file names being output contain... unusual c...

What is the most appropriate .NET exception to throw upon failing to load an expected registry setting?

I have an application which tries to load some expected registry settings within its constructor. What is the most appropriate .NET Exception from the BCL to throw if these (essential, non-defaultable) registry settings cannot be loaded? For example: RegistryKey registryKey = Registry.LocalMachine.OpenSubkey("HKLM\Foo\Bar\Baz"); //...

Removing an optional value type element from a SOAP message sent via a WCF proxy

We have a wsdl specifying a datetime element. It is nullable, in the sense that minOccurs=0. However, using svcutil to generate a proxy class does not give us a .net nullable DateTime property, so how best can we make the proxy class serialise the message to a SOAP message that does not contain the datetime element? ...

Access LINQ-2-SQL DataContext in entity class

Is there any simple way to access the DataContext in a linq2sql entity class. I'm trying to create something like EntitySet but I cannot figure out how the EntitySet has access to the context that created the entity object in the first place. I want to have a regular linq2sql entity class with a way for the class to access the DataCont...

How do I determine if a WPF window is modal?

What's the easiest way to figure out if a window is opened modally or not? CLARIFIACTION: I open a window calling myWindow.ShowDialog(); I have a footer with an "OK" & "Cancel" button that I only want to show if the window is opened modally. Now I realize I can set a property by doing this: myWindow.IsModal = true; myWindow.ShowDia...

When to separate certain entities into different repositories?

I generally try and keep all related entities in the same repository. The following are entities that have a relationship between the two (marked with indentation): User UserPreference So they make sense to go into a user repository. However users are often linked to many different entities, what would you do in the following examp...

Javascript Error thrown by AjaxToolKit in .NET only on some machines

We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my Error Console: Error: [Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from ...

listview item cut style in .NET?

Hi All, How do I achieve the equivalent of the LVIS_CUT style for a listview item? It looks like it's not exposed by the framework? Should I P/Invoke? Edit: LVIS_CUT is a Win32 style that affects the look of the item: It grays the item image. You can see it in action in Windows Explorer: Select a file and type Ctrl+X. TIA. ...

Webservices - Java or .NET?

I need to implement webservices in an upcoming project and wanted to know what are the main points to base the decision on whether to implement using java or .NET I'm a C++er... ...

How difficult is it to develop an ASP.Net web application that runs under Mono and Windows?

We are about to develop a web app from scratch using ASP.Net, and would like it to be as platform-agnostic as possible. As far as I know, the only two options for this are IIS on windows, and Mono (via Apache) on Linux. The app will be follow the MVC architecture, so with all of this in mind, how difficult is it to develop the applicati...

How do you manage and organize your game components?

Hi folks, in my spare time I'm engaged with writing a little game using Microsofts XNA framework. Reviewing the very first prototype which I wrote to get aquainted with XNA, I found it annoying that there is no possibility to structure my (drawable) game components in a hierarchical manner. I was close to implement a kind of Composite(D...

Error in retrieving and binding to a datagridview from a mysql stored procedure with concat()

Everytime i retrieve data from a mysql stored procedure with a concat function an error will occur after binding the datagridview to the datatable that holds the returned rows. ...

How do I convert C# characters to their hexadecimal code representation.

What I need to do is convert a C# character to an escaped unicode string: So, 'A' - > "\x0041". Is there a better way to do this than: char ch = 'A'; string strOut = String.Format("\\x{0}", Convert.ToUInt16(ch).ToString("x4")); ...

How can I recover a class from the DataSet that it was cast to by the Web Services proxy class?

Background I have made a Web Service in Visual Studio, and I'm trying to consume it using the automatically generated proxy class. The Web Service returns a class that I have implemented, containing a List. Question The proxy class has automatically generated methods to send the SOAP to the web service. It uses the Invoke() method to ...

Can strong naming an assembly be used to verify the assembly author?

After reading the proper article in MSDN and related stackoverflow.com questions here, I finally return to the community. To which extent can a strong-named assembly be verified to avoid tampering? Is it possible to use strong-naming to verify an assembly author? The first question arises after reading this CSharp411 article, which ...

Safe storing of auth token using .NET

I'm currently working on desktop application which calls third party API. After authorizing against their "web service", a kind of user token is returned which should be stored locally (even if user closes application). So I'm looking for solution to encrypt this token with user specific key. Does Windows (and .NET) provide some stand...

Errors in Windows Forms controls in designer view

On occasion, I get the following error in design mode of some user controls in Visual Studio 2008: The file 'UserControl.vb' does not support code parsing or generation because it is not contained within a project that supports code. It doesn't happen on a consistent basis, but it happens enough to be annoying. Are there any...

Reference 3.5 assembly from 2.0 application?

I have an assembly that is targeted for .NET 3.5. I have an application targeted for .NET 2.0 and wonder if I should have any trouble referencing the 3.5 assembly from the 2.0 application. I understand that the IL is supposedly the same, so I'm assuming that it will work, but would like to hear some experiences from others who have tri...

Microsoft Visual Studio SDK DSL Tools - Any serious takers?

We are considering Microsoft DSL toolkit for creating some abstract designers. I already did some POCs, but would like to get some opinions on the same. Any one here to share their experiences working with Microsoft DSL Toolkit and T4? Also, any pointers to open source DSL projects will help - Eg. Microsoft Service Factory modeling edit...