.net

CLR on unsafe code and pointer point to array??

how do CLR interact with unsafe code I found various result on Google but i couldn't understand. I am also confused that is Garbage collector work on unsafe code? if yes than how? I cant point pointer to Array,s first element I try this code unsafe{ int[] a = { 4, 5 }; int* b = a; } but I got that error Error :Cannot implicitl...

Is there any documentation for the PAP protocol used by the Blackberry Push Service?

I'd like to connect to the Blackberry Push Service using .NET, but the available SDK is in Java and does not include source code for the server components. I could not find a clear document anywhere describing the communications protocol used by the push service. Any help is appreciated. I did see this post, which provides a few clues...

facebook development using C#

I see a lots of different framework for development of app in asp.NET using C#. Please suggest a stable and well document framework for FB development. ...

Nested select top 1 in Linq

Hey, having some problems figuring this one out. select *,(select top 1 chicken_nr from chicken_photo where chicken = code order by [sort]) as Photo from Chicken Code is a column in Table Chicken Basically getting the cover photo for this chicken. To make it clearer, I want it to return multiple rows from table Chicken. But only a s...

Future of community projects in .Net

Hi guys, I've been lately thinking about future of open source community projects in .Net. What raises this problem is actually Microsoft devouring all those projects and replacing them with its own ones. Every new version of .Net framework brings not only clr or language improvements, but also some super new features which slowly, but ...

Optimizing memory footprint of a .NET application with a huge number of instances

I have an application that holds huge number of instances in-memory for performance reasons, and I don't want to write it to disk or any other place, just hold it all in-memory. public class MyObject { public string Name; public object Tag; public DateTime DateTime1; public DateTime DateTime2; public DateTime DateTi...

Drawing on Image in .NET - how to erase?

I'm planning to allow user drawing shapes and lines on image using mouse. If the background is solid, it's quite easy to build the eraser tool (simply fill with background color). But how to make it with image as background? ...

How to define the default implementation of an interface in c#?

There is some black magic code in c# where you can define the default implementation of an interface. So you can write var instance = new ISomeInterface(); Any pointers? UPDATE 1: Note that is did not ask if this is a good idea. Just how was it possible to do it. UPDATE 2: to anyone seeing the accepted answer. "this should be tre...

Windows Phone 7: System.Runtime.InteropServices.Marshal does not work with COM

I have two questions. 1)Does Windows Phone 7 support COM? .NET Framework knows such attributes like ComVisible, but I am not sure after all. 2)System.Runtime.InteropServices.Marshal misses any COM functions. Particularly, if the first question is answered positive, I miss StringToBSTR and GetObjectForNativeVariant. I am sure both funct...

EntityFramework 4.0: InvalidOperationExecption: Multiplicity constraint violated

Hi, we have recently upgraded our software to .NET 4.0 and EF 4.0 (without self-tracking entities) (former .NET 3.5 SP1). Now a new exception is raised in former working code, which we do not understand. We have an entity called Resident, and another entity called ResidentExtension, which extends the already large Resident entity with ...

Regular expression convert url to hyperlink

I've googled some code that converts an url into a hyperlink using bbcode The code is : // format the url tags: [url=www.website.com]my site[/url] // becomes: <a href="www.website.com">my site</a> exp = new Regex(@"\[url\=([^\]]+)\]([^\]]+)\[/url\]"); str = exp.Replace(str, "<a href=\"$1\">$2</a>"); // format the img tags: [img]www.web...

Erasing pixel with .Net GDI+

How can I set the alpha channel of a pixel to zero using .Net GDI+ or API calls? How can I set to transparent a shaped area (for instance, having sort of an"Erasing" brush and using it with FillEllipse() or FillRectangle() methods) ? Thank you. ...

Why should an abstract class implement an abstract method of an abstract base class ?

In the following example, the class Derived implements the abstract method method from class Main. But I can't think of a reason to fill in the method body in the abstract Derived class' implementation. Surely I should only implement abstract methods within real classes. So how can I avoid doing it? What else can I do? abstract class ...

How to get Dotfuscator to work from command line?

I've tried dotfuscator.exe /in:myassembly.dll, According to the command line documentation, this should dotfuscate my DLL. It just immediately returns to the command line, doing nothing. When I try dotfuscator.exe dotfuscator1.xml Dotfuscator GUI appears with that .xml file loaded instead of operating on my assembly. Note I'm ...

What is C# for C " FILE *f;"?

I am a beginner in C# I wonder how to write in C# C's static void example(const char *filename) { FILE *f; outbuf_size = 10000; outbuf = malloc(outbuf_size); f = fopen(filename, "wb"); if (!f) { fprintf(stderr, "could not open %s\n", filename); exit(1); } fwrite(outbuf, 1, outbuf_size, f); fclose(f); } Plas...

Declaration suffix for decimal type

If I want use a decimal-literal in code, I have seen that there exists the m-suffix (where m stands for money). Is this appropriate for any decimals or exists a more general assigment (d stands for double, that is for shure not the right thing although a direct conversion is supported). object decimalValue=2m; Please note, I took the ...

how to ensure that VSVARS32.BAT batch file have permanent effect?

If I need to use microsoft C# compiler from the normal command prompt, it says right here how and it says right here how I set the environment variable (by running VSVARS32.BAT). I execute it and after that I can run "csc" (the compiler). However the effect seems to disappear when I close the command line window that run VSVARS32.BAT Is...

.NET Equivalents to Java Crypto stuff

Hi Could anybody tell me what the equivalent .NET classes/methods are to the following Java methods: decryptCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); decryptCipher.init(2, getKey(0)); decryptCipher.doFinal(data); where getKey() returns an object of type SecretKeySpec (data is dummy): public static Key getKey(int cipher) {...

ConfigurationManager Class

How do you use the COnfigurationManager class to read and write to the settings file? ...

AD / Forms authentication

Hi, I am developing an application that will mainly be used internally and want to know how i can automatically authenticate users against Active Directory without prompting them to login. However, when a user is not automatically authenticated (i.e. they have connected via the internet) I want to display a form that will authenticate...