nullreferenceexception

Context, Membership, Etc Null when using MVC on IIS7

I'm sure this must be something simple that I'm missing. I'm using MVC Routing in my Forms applicaiton for Url Routing. On most of the forms I access the Context, Membership, etc. On my dev machine and on IIS6 everything works fine. I'm just trying to get to work on IIS7 and no luck. The Routing works as it should, but anytime I try...

Why does ResourceManager.GetResourceSet return null on the first request after a build? (C#)

I'm working on a large-ish web application built in C# (asp.net). I've got a simple aspx page that serves localized strings to the client browser for use in javascript controls. To get the strings, I do the following: ResourceManager _resources = new ResourceManager(_pathname, typeof(ARM).Assembly); ResourceSet rs = _resources.GetReso...

C# Object reference not set to an instance of an object.

I'm trying to make it so that when you double click the tray icon, my program will either a) minimize if it is in the normal state, or b) return to normal state if it is minimized. I have the following code (where TrayIcon is a NotifyIcon control): public partial class MainForm : Form { public MainForm() { ...

(c#) NullReferenceException??? I've got a constructor what's going on?

I am trying to write code for an assignment for the c# intro class at my college but am ahead and am running into problems. I am getting a NullReferenceException when i run the program - i think the problem is coming from the fact that i am creating a 'Line' which contains the 'Point' class... i have tried for 3hrs to fix this - any help...

NullReference at XML-Operations

I'm getting a NullReferenceException upon trying to read an attribute of an xml-file - what attribute to read from what element is defined by user-input. The StackTrace keeps redirecting me to this line (marked) XmlDocument _XmlDoc = new XmlDocument(); _XmlDoc.Load(_WorkingDir + "Session.xml"); XmlElement _XmlRoot = _XmlDoc.DocumentEle...

DataView NullReferenceException in OnListChanged

I have a fairly complex WinForms app that uses data binding to tie strongly typed DataTables to controls (not sure if this fact matters here). An exception gets raised when a change to a column triggers logic that updates another column on that same row (or at least this is my theory). An example: a Customer record is bound to a Comb...

Having trouble with XmlDocument C#

I'm having trouble getting my program to read this XML file properly, it will need to write to it also but not yet. Just note that this is only a little bit of the code XmlDocument InstalledList = new XmlDocument(); InstalledList.Load(AppsInstalledFileNamePath); //Sets the PackageNode to the correct part of the XmlDocument XmlNodeList ...

How to use PortMode.OptimizedSingleReissueReceiver in an Interleave? (Microsoft CCR)

Hi, I have read a post on the Microsoft CCR forum on reducing the overhead of calls to Port.Post() [ref.: PortElement Instantiation in the CCR] and I was wondering if there is a similar way to bind a port to its receiver in order to use the port in OptimizedSingleReissueReceiver mode in an interleave arbiter? I have implemented the fol...

System.NullReferenceException

Hi, I have a windows application developed in VS.NET 2003. sometimes I am getting System.NullReferenceException exception from CallWindowProc(). Here is the stack trace of the exception Error_Stack_Trace : at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr...

ASP.NET processing abruptly stopped on IIS 6.0

Hi there we noticed a rather strange behavior on one of our web applications. When debugging it on a local developer workstation, everything is processed fine (using Cassini Developement Webserver). When published on a remote webserver using IIS 6.0, processing runs fine about 4 or 5 minutes, then abruptly dies. I'll explain later what...

Regex.MatchData returning null: why not Option[String]?

Is there any particular reason why Regex.MatchData.group(i: Int): java.lang.String returns null rather than Option[String]? Is there a "Scala Way" to handle nulls in Scala? ...

Html.TextBox() throws System.NullReferenceException

I get this error when I invoke the Edit Action of one of my controllers. Here is the C# code of the Edit action method [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(cedetails detailToEdit) { validateDetail(detailToEdit); if (!ModelState.IsValid) return View(); try { ...

avoiding null reference exceptions

Apparently the vast majority of errors in code are null reference exceptions. Are there any general techniques to avoid encountering null reference errors? Unless I am mistaken, I am aware that in languages such as F# is it not possible to have a null value. But thats not the question, I'm asking how to avoid null reference errors in la...

[C#] Delegate Calling in a Constructor

I've run into an easily solved but a design problem I've not encountered in my young life yet. I have a class that needs to go through a few setup procedures before anything else happens. However, during the construction of this class, I have in the constructor's parameters a delegate that can be passed so that the user can add their o...

How can a readonly static field be null?

So here's an excerpt from one of my classes: [ThreadStatic] readonly static private AccountManager _instance = new AccountManager(); private AccountManager() { } static public AccountManager Instance { get { return _instance; } } As you can see, it's a singleton-per-thread - i.e. the instance ...

Referencing a custom obj, declared as a static res in xaml, is null. Why?

I have a small Silverlight 3 test application. This is an exercise in learning Silverlight, XAML, binding, etc. I have a small test class (Test), which has three properties; Val1, Val2, and Sum. I have declared a resource in the XAML as follows: <UserControl.Resources> <app:Test x:Name="xamlTestObj"></app:Test> </UserControl.Reso...

nHibernate not loading third-level properties (non-flushable caching)

I started switching some pre-existing nHibernate code in a Sharepoint-based ASP.NET project from eager loading and a new session every database hit, to lazy loading and a session for the duration of the HTTP request, and started running into a problem. When we create an Item in this system, there are some many-to-one relationships that ...

Why 'Object reference not set to an instance of an object' is not more descriptive?

As a developer, we often encounter that exception: NullReferenceException with the well known error message: Object reference not set to an instance of an object Is it not possible for the .NET framework to return something a little bit more meaningful? Something such as: Object of type X named Y not set to an instance of...

How to test for an empty generic.dictionary collection?

How do I test a generic dictionary object to see whether it is empty? I want to run some code as follows: while (reportGraphs.MoveNext()) { reportGraph = (ReportGraph)reportGraphs.Current.Value; report.ContainsGraphs = true; break; } The reportGraph object is of type System.Collections.Generic.Dictionary When running this...

Make a variable be required - to evade NullReferenceException?

[SOLVED] - The mistake was mine, that I didn't link World (world_) to the entity, so that was null. Thanks for the explanation everyone! As you may know by now, I'm making a game engine/framework, and I've got stuck linking stuff with references to each other. Example: public void Attach(Entity Entity) { entity_ = Entity; en...