.net

Binary data in .NET? (C++/CLI)

What's the prefered way to store binary data in .NET? I've tried this: byte data __gc [] = __gc new byte [100]; And got this error: error C2726: '__gc new' may only be used to create an object with managed type Is there a way to have managed array of bytes? ...

Best way to inject your code into running WPF application

Here is my task: Inject custom managed code into running managed WPF application (i.e. my code should run in other AppDomain) Injected code must be executed on UI thread When I say 'best' I mean that: Injection process must be as stable as possible (no thread deadlocks, etc.) Code should run on x86 and x64 platforms without problem...

One-to-one relationship modeled in OO

In a software system a one-to-one relationship must be modeled between two objects where an active status exists for the relationship. In other words, ObjectA has a one-to-one relationship to ObjectB (without a back pointer) where the relationship can be either active or inactive. There might also be additional attributes associated wi...

Keep getting The provider requires SessionState to be enabled on IIS 6

While trying to deploy a simple asp.net mvc project on an IIS 6 server, I keep getting this error "The provider requires SessionState to be enabled". To rule out that I am doing something wrong, I am now trying to deploy just the template you get when you start a new asp.net mvc solution in vs2008. And yes, I have enabled session state ...

What's your opinion on MS CAB (Composite Application Block)?

I'm in the process of evaluating the use of CAB for a new .net 3.5 winform project I plan to use the Infragistics toolset, which is known to be 'CAB compliant' While CAB has the immediate upside of letting me focus on my business instead of coding basic docking/login/etc code, I feel like I would be able to achieve the same level of fu...

What are the best C# .NET books?

What are your top 3 all-time best C# .NET books? And why? They could be for specific areas of .NET or be more general books. ...

Where can I see some good examples of what WPF is capable of?

What is some good software that is written with WPF? I keep hearing about what it can do. I would like to see it in action. ...

How to create XElement with default namespace for children without using XNamespace in all child nodes

I'm trying to use System.Xml.Linq to create XHTML documents. Thus, the vast majority of the nodes in my trees ought to use this namespace: http://www.w3.org/1999/xhtml I can create XElement nodes scoped to this namespace easily enough, using an XNamespace, like this: XNamespace xhtml = "http://www.w3.org/1999/xhtml"; // ... new XElem...

What's a reasonable version of Windows to support for a new .Net application?

If I develop a .Net application that's going to run on WinXP and Vista, as well as on a modern Mac or Linux under Mono, what are older versions of Windows where I will have to start thinking carefully if I want to support them? Does Windows 2000 for example run .Net and is it capable of any version of the runtime? Usually, older systems ...

When is it acceptable to call GC.Collect?

The general advise is that you should not call GC.Collect from your code, but what are the exceptions to this rule? I can only think of a few very specific cases where it may make sense to force a garbage collection. One example that springs to mind is a service, that wakes up at intervals, performs some task, and then sleeps for a lo...

Atomicity of object references

Hi, I just came across the question - is the access of an object safely possible across threads in C#. E.g. with the code //Somewhere long ago MyClass myVar = new MyClass("First Instance"); //Then later, happening at the same time //In thread one myVar = new MyClass("Second Instance"); //In thread two myVar.PrintName(); I don't ca...

DataSource for User Control

I am buidling a user control. Currently it consists of a textbox and a button - as a learning experience. This will be used as a basis for a more useful control. I want to add a DataSource, display member and ValueMember. Here is my code for the datasource. It will display in the Properties editor, but is disabled and grayed out. Wha...

tooltip appearing behind the form/window! (C# / VS 2008)

For some strange reason, my toopltip in the VS 2008 C# winforms application shows up behind the form! It's very frustrating and I can't figure out what I should do. Anyone face this before? Ideas? (PS - I'm doing a toolstip.show programmatically within the form) ...

How to create a 13 month moon based Calendar in .net

hi i would like to create a custom calendar, this calendar will have custom month names and day names it will contain 13 months with 28 days each do i need to create and entire Culture or can i just created my own System.Globalization.Calendar implementaion? ...

Linq to Sql: SubmitChanges() adds more objects to database then I've attached

I have the problem that when calling SubmitChanges() objects that have not been attached to a collection or added using InsertOnSubmit(), are still being inserted into the database. I read online that when assigning an object to a property that represents a foreign key, this object is automatically added to the collection of objects to ...

Any way to get the size attribute from LINQ generated class members ?

I would like to avoid to specify manually maxlength attributes for all form input elements, and instead to use size information from the Data Model if possible: e.g. <%= Html.TextBox("Titel", ViewData.Model.Titel, (object)new { @maxlength = "10" })%> would it be possible "translate" the DbType Attribute in the LINQ class ? [Column(S...

Why does Vista report that my Windows account not being in Adminstrators Role?

Under Windows Vista, when I check whether my current user account is in Administrators role, I am getting a negative, as shown in the following picture. Can anyone tell me why I am not in the Administrators role? When I do the check if I am in "Debugger Users" role, I am getting "True" Thank you. ...

Another C# question about references/collections/value types

I have the following code: public class Test { public static void Main() { List<Person> list = new List<Person>(); Person person = new Person() { Name="Chris" }; list.Add(person); person = new Person(){ Name="Wilson the cat" }; list.Add(person); Console.WriteLine(list[0].Name); Console.WriteL...

Castle ActiveRecord / NHibernate - Password Encryption or Hashing

What is the proper way to work with Passwords you don't want to store in clear text in a database? What are my options in NHibernate / Castle ActiveRecord? UPDATE: I was interested in how others handle this with NHibernate / Castle ActiveRecord. And if there was anything built into NHibernate or Castle ActiveRecord. ...

How do I embed Gecko using gecko-sharp on Mono/Windows?

Gecko is the rendering engine for Firefox. Using gecko-sharp it is possible to embed it to any Mono/GTK# program. There is a sample application called GladeSharpBrowser for doing this. I could manage to build it using a modified project file, but it is crashing. This sould help you reproduce the problem: I have used SharpDevelop 3.0 and...