.net

.NET 3.0 Unit Testing getting System.MethodAccessException calling .NET 2.0

Is there any way to get around this exception? Can I not call a .NET 2.0 from 3.5? I have to write .NET 2.0 to maintain capability with BizTalk 2006/R2. But I would like to test with VS2008 Unit Tests to be consistent to other non-BizTalk code that we are testing. Test method ABC.UnitTest.UnitTest1.TestReferenceCode1 threw exception...

Changing ASP.NET tag formatting

When I drag a Label control to my document, I get the following code : <asp:Label ID="Label1" runat="server" text="Label"></asp:Label> I prefer my code to look like the following instead : <asp:Label ID="Label1" runat="server" Text="Label" /> How can I get .NET to do this by default? I looked in Tools -> Options -> Text Editor, whe...

Add a custom button to titlebar in Windows Mobile 5

Is there a way to add a button to the title bar in windows mobile 5? (Next to the X or OK button.) I have an app that locks the users out of the start button, so I need to create an alternate way of launching the help file. Failing the title bar, I will look for a way to customize what a hardware button does. I am using C#. ...

SPNavigationNode.IsVisible property not working in sharepoint as expected.

I want to hide a quick launch node in a sharepoint site, but it's not working as expected. :( My code is as under: using (SPSite spSiteTest = new SPSite(serverUrl)) { using (SPWeb mySite = spSiteTest.OpenWeb()) { SPNavigationNodeCollection quickLau...

How to show that the double-checked-lock pattern with Dictionary's TryGetValue is not threadsafe

Recently I've seen some C# projects that use a double-checked-lock pattern on a Dictionary. Something like this: private static readonly object _lock = new object(); private static volatile IDictionary<string, object> _cache = new Dictionary<string, object>(); public static object Create(string key) { object val; if (!_cac...

How to fix an endpoint/configuration error using WCF in VB.NET

I'm working with a small web page that is meant to assist the users of my application. This web page takes a file and sends it to a central server, which then does something with the data and returns a result. I created this application some time ago and am coming back to it recently. I am getting some kind of configuration error right n...

How do I debug a .NET executable at MSIL-level?

I have a .NET executable file that I need to debug. I would like to step into it so that it stops on the first instruction and have a visual interface for single-stepping, breakpoints, etc. This seems like it should be easier but I haven't yet found a solution! I read about DbgCLR.exe on the web but I can't find that file on my system...

marking IronPython class as serializable

is it possible to do this in IronPython and if it is, how? ...

Using generics in Unity ... InvalidCastException

Hi, My interface definition is: public interface IInterface where T:UserControl My class definition is: public partial class App1Control : UserControl, IInterface The unity section of my app.config looks as below: <unity> <typeAliases> <typeAlias alias="singleton" type="Microsoft.Practices.Unity.Contai...

Convert Unicode char to closest (most similar) char in ASCII (.NET)

How do I to convert different Unicode characters to their closest ASCII equivalents? Like Ä -> A. I googled but didn't find any suitable solution. The trick Encoding.ASCII.GetBytes("Ä")[0] didn't work. (Result was ?). I found that there is a class Encoder that has a Fallback property that is exactly for cases when char can't be convert...

How can I get a dataset to populate from an RDL file?

I have an RDL report file and I would like to somehow "run" the report and get the dataset that would be used to fill the report. What I'm trying to do is get a raw data extract from the data that would be used to fill the report, without actually showing the report to the user. Is this possible? ...

HttpBrowserCapabilities doesn't detect 64-bit Windows, what's the built-in alternative without parsing user agent string?

The two available detection options for Windows in System.WebHttpBrowserCapabilities are: Win16 Overloaded. Win32 Overloaded. If 64-bit isn't testable, the Win* properties seem rather useless. Besides parsing the user agent string, what's often used in place of these properties (maybe combinations of them)? ...

Initialize byte array from a portion of existing byte array c#

Is there are an easy way to initialize byte array from portion of existing byte array. In C language it is possible to use pointer to say like char s[10] = new char[10]; char* b = s + 5; Is it possible to do that in c#, like: byte[] b = new byte[buffersize]; byte* header = b + 5; byte* data = b + 25; ...

.Net Windows Services and InstallState file - is it really needed?

I've got a number of managed code Windows Services for which we use the Frameworks InstallUtil tool to install into the service control manager. This tool creates a new file at install time with an extension of .InstallState. I have experimented with deleting this file and an uninstall still works fine afterwards. So my questions is, wh...

MessageBox.Show(TimeSpan)

i would like to show a TimeSpan in a MessageBox but am getting an error: DateTime date1 = new DateTime(byear, bmonth, bday, 0, 0, 0); DateTime datenow = DateTime.Now; TimeSpan age = datenow - date1; MessageBox.Show(ToString(age)); Error 1 No overload for method 'ToString' takes '1' arguments how do i output a messagebox with Ti...

Tips on refactoring existing .net applications to support localization?

We're going global. I've been tasked with refactoring our existing products to support localization. Last week I shunned using resource files (.resx) in favor of a home-baked database look-up method. After hitting a serious snag with that, I'm back to the microsoft way of using resx. All the documentation I've seen so far details how...

Convert French to ASCII (French speakers are wanted)

i need to convert French text to most correct analogue in ASCII. Let me explain. In German you should convert ä to ae, this is not simple removing of diacritics, it is finding most correct analogue. Please help me with French. I found that there is no programmatic way to do it, i create Dictionary<char, string>. To convert (+ capitals):...

How to get an BITMAP struct from a RenderTargetBitmap in C++/CLI?

I've got a WPF RenderTargetBitmap in C++/CLI and I want to be able to create a BITMAP structure from it to use with BitBlt. I've not worked with BITMAP or RenderTargetBitmap much before, so any thoughts would be great! ...

Updates to .NET Compact Framework in 2010?

This question (http://stackoverflow.com/questions/245566/net-compact-framework-4-0) asked this back before the release of VS 2010. The answer basically said to wait for the release. Now that the release is here, does anyone know? Is there an upgrade/update to the .NETCF? something past .NETCF 3.5? Update: You can go here and vote to...

How can I generate a flat excel file from a .rdl report?

I have a .rdl report that formats data as a report. I want to export that data to excel as a flat table with the raw data that was returned based on the params in the report. The default excel export looks just like the report which isn't what I want (I just want rows and columns). Is there an easy way to do this? ...