.net

NullReferenceException on this C# code.

Here is the entire code for my class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Xml.Linq; namespace SharpDIC.Entities { /// <summary> /// Represents a forum on the Dream.In.Code website. /// </summary> public class Forum { //Forum inf...

ADO.NET Entity Framework SaveChanges is not working

Hi, I have a .NET 4 WinForms app that uses the ADO.NET Entity Framework. Some code that was working perfectly has decided to stop working and although I've tried to figure out what changed that could cause this, I am stumped. This code looks perfectly functional to me and WAS working as intended. Anyone have any ideas? Here is the code...

Linking Functions In a C# DLL from a C# Application

What is the proper way to link to functions in a C# DLL from a C# application? This is how my DLL looks: namespace WMIQuery_Namespace { public class WMIQuery { public static string GetPortName() { /* Does some stuff returning valid port name. */ return string.Empty; } pu...

.NET settings.settings Variable Confusion

Hi, I'm new to WPF applications and I am dealing with an app that is storing some simple variables in settings.settings via the grid GUI in Visual Studio. The problem is that somehow two boolean variables have been set to true, and I can't seem to reset them. If I go back to the setting GUI, I can see that the value is set to "False", b...

asp .net mvc ajax submit

Hi, I am facing a problem that's driving my crazy for sometime. I have an asp .net mvc page(.ascx). This view has a form which can be ajax submitted to a controller action. I have an ajax submit button that posts the form. In the view I have some if conditions as follows If(Model.SampleID.HasValue) { alert('sample created');...

Can't safely lock a value of a ConcurrentDictionary

Hi, I'm having trouble locking on an item within a Collection - specifically a ConcurrentDictionary. I need to accept a message, look up that message within the Dictionary and then run a lengthy scan on that. As the program takes a lot of memory, after the scan the objects return true if they think its a good time to delete it (which I...

Logging with NLog into an Isolated Storage

Hi, I use the NLog Libary (http://nlog-project.org/) within my C# Win Forms to do the logging. Has anyone some experiance if it's possible to write the Logfile into an "IsolatedStorage" with this NLogger? Thx 4 answers ...

Are .NET try / catch cheap?

Possible Duplicate: Performance Cost Of 'try' I stumbled upon this remark in "Best Practices for Handling Exceptions" at MSDN: " using exception handling is better because less code is executed in the normal case" in the context of whether one should check for the state of an object before calling a method or just call the m...

Get users email addresses from Active Directory group

Hey, I need some simple test program which will allow me to set AD group name(e.g. testdomain.groupname) and based on this group name it retrieves me all the users(with subgroups as well) email addresses. Any code snippet will be highly appreciated. Thanks ...

Publishing in .NET produces "Application Files\MyApp_SomeVersionNumber" How to get this number?

When I publish my app it gives me a name like Application Files\WPFMapLauncher_1_0_0_43 I can get the 1.0.0.0 with this : String version = Assembly.GetExecutingAssembly().FullName; But how can I get the 43? ...

Why does .NET's StringValidator's Validate method throws an exception when it doesn't succeed?

As you can see in the MSDN StringValidator documentation, the Validate method returns void. If validation doesn't succeed the Validate method throws ArgumentException. I thought that "You only throw an exception when something exceptional happens". Surely a validator that failed to validate isn't exceptional.. Why not return bool? What a...

How to get a single photo by ID from Picasa using the google-gdata .net API

I'm trying to use the .net API library to get a single image by ID from Picasa. So far, I've tried to find the correct call by doing: new Photo(); but there are no constructor params to tell it which photo to get new Entry(); same as above PicasaQuery.CreatePicasaUri; but I have to specify the albumId as well then, which I don't have...

C# .Net 4 Retrieve shared folders

I'm creating a WPF file explorer treeview (in C# 4) and I need it to work with UNC. For example, lets say I have these shared networks folders: \\share\test1 \\share\test2 \\share\test3 \\share\test4 If I only have \\share, how can I determine what shared folders are within that path? \share is not a shared folder in and of itself. ...

Entity Framework 4.0, Can't find connection name

I am trying to run a unit test with N-unit in a project. The project has the .edmx file in it, so it's not a multi-project problem that I see a lot of people. I kept all the defaults from what was auto generated by the Tool. My Web.config file appears to have the connection string in the <connectionStrings>: <connectionStrings> <add nam...

Passing anonymous typed group to a function

I needed to pass a IGrouping on an anonymously typed index to a function. List<DataClass> sampleList = new List<DataClass>(); var groups = sampleList.GroupBy(item => new { item.A, item.B, item.C }); I needed to process each of the groups with a function. So I wrote this which works. static void ProcessGroup<T>(IGrouping<T, DataCl...

What is the regex for *abc?

I am trying to use Regex to find out if a string matches *abc - in other words, it starts with anything but finishes with "abc"? What is the regex expression for this? I tried *abc but "Regex.Matches" returns true for xxabcd, which is not what I want. ...

REST library which support Windows Phone 7 and silverlight ?

Are there any .net REST libraries which support Windows Phone 7 and silverlight? ...

how to register COM+ application from VS Setup

I'm trying to create an installer for my serviced component (queued component). Once the .NET DLL is installed on client machine, I want to register it as COM+ Application, as if by invoking regsvcs MyAssembly.dll. What is the best way to do it? Can I invoke regsvcs from Windows Setup program, once it has installed my .NET DLL on client...

Why am I forced to rebuild my project to see changes made to controllers in ASP.NET MVC?

I'm using ASP.NET MVC 3 Beta and for some strange reason, if I change a controller's action and load the action in a browser, it doesn't recompile the assembly to incorporate the changes made. Maybe I'm spoilt from how things were in ASP.NET Webforms, where there was dynamic on-the-flycompilation of code-behind files, but I think this sh...

Inverse list ....

In an interview question, I saw this. How inverse the content of this list without loose the references. List<string> list = new List<string>() {"AA", "BB", "CC" }; Update : The question is more like this, you have : public void ReversedList<T>(IList<T> listToReverse) { // To be implemented } sample the list has 1,2,3,4 and mus...