Hello,
I've a table Role associated in 1-many relation with table User in my database. I've created LINQ mapping classes manually:
[Table(Name="Role")]
public class Role
{
private EntitySet<User> _Users;
[Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
public int RoleID { get; set; }
[C...
I am using the following methods to serialize and deserialize .NET objects:
public static string SerializeToBase64(object data)
{
var stream = new MemoryStream();
var formatter = new BinaryFormatter();
formatter.Serialize(stream, data);
stream.Position = 0;
return Convert.ToBase64String(stream.ToArray());
}
public s...
Okay so I'm quite new to ASP.NET and the MasterPage concept and there's an error I just can't figure out.
This is a part of my default.aspx:
<asp:Content ID="ContentLoginContent" ContentPlaceHolderID="LoginContentPlaceHolder" runat="server">
<div id="ContentLoginDiv">
You've got <asp:Label ID="MemberCreditLabel" runat="server" Text...
In my database I have a table called
StaffMembers
when I bring this into my .net Project as through linq-to-sql an entity class StaffMember is created
Now I have also created a partial class StaffMember in my project also, to add extra properties that I use in other top layers. eg. IsDeleted property. This partial class also inherits a...
I have a class Cell:
public class Cell
{
public enum cellState
{
WATER,
SCAN,
SHIPUNIT,
SHOT,
HIT
}
public Cell()
{
currentCell = cellState.WATER;
MessageBox.Show(currentCell.ToString());
}
public cellState currentCell { get; set; }
}
I then try to u...
I am getting a NullReferenceException when the following code is executed. I have also noticed that the nested table appeared on a new page when I added in the code that wrote cells to the main table. It doesn't occur if I take out the two loops that write cells to the main table.
<%@ Page Title="" Language="C#" MasterPageFile="~/Main...
I have a null in one of arguments in String.Format() so call throws NullReferenceException. Why does check take place even the argument isn't in resultant string?
class Foo
{
public Exception Ex { get; set; }
}
class Program
{
public static void Main(string[] args)
{
var f1 = new Foo() { Ex = new Exception("Whatever...
I'm working on a large project where, even with 10s of 1000s of automated tests and 100% code coverage, we're getting a ridiculous number of errors. About 95% of errors we get are NullReferenceExceptions.
Is there any way to enforce null-checking at compile time?
Barring that, is there any way to automagically enforce null-checking in ...
I'm using values from a row on a datagridview, to build an image path to pass to a picturebox.
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow currentRow = new DataGridViewRow();
currentRow = dataGridView1.CurrentRow;
string valueJob = currentRow.Cells[2].Value.ToString();
string...
Hello again, I think the title says it all. I'm using
Reminder fifteenMinReminder = new Reminder();
fifteenMinReminder.Minutes = 15;
fifteenMinReminder.Method = Reminder.ReminderMethod.email;
entry.Reminders.Add(fifteenMinReminder);
on a brand new entry (where Reminder and Reminders are Nothing), but I cannot add a reminder using the ...
Resharper is showing a "Possible System.NullReferenceException" warning. I however can't see how I can get one.
public class PlaceController : PlanningControllerBase
{
[Authorize]
public ActionResult StartStop(int id)
{
if (Request != null && Request.Cookies != null && Request.Cookies["place"] != null)
{
...
From previous experience I had been under the impression that it's perfectly legal (though perhaps not advisable) to call extension methods on a null instance. So in C#, this code compiles and runs:
// code in static class
static bool IsNull(this object obj) {
return obj == null;
}
// code elsewhere
object x = null;
bool exists = !...
I have a static class with serveral static methods. In these methods, I'm trying to access the current thread's context using HttpContext.Current. For example:
var userName = HttpContext.Current.User.Identity.Name;
However, when I do that, I receive a NullReferenceException, the infamous "Object reference not set to an instance of an ...
How do I deal with null fields in GetHashCode function?
Module Module1
Sub Main()
Dim c As New Contact
Dim hash = c.GetHashCode
End Sub
Public Class Contact : Implements IEquatable(Of Contact)
Public Name As String
Public Address As String
Public Overloads Function Equals(ByVal other As Contact) As Boolean _
...
I have a web form that will dynamically create a number of checkboxlist filled with data based on the number of row in database. Then this is added to a placeholder to be displayed.
theres a button when clicked, will add the selected check boxes value into database but right now when the button is clicked and after the postback, the pa...
A Technical Lead asked me the following:
He created a class, declared an object and initialized it. But in some circumstance we may get "null reference" exception.
He commented that there are 1000 possible reasons for such exception and asked me to guess a single reason.
I am unable to figure it out. What is (are) the reason(s) ,we may g...
private void BindCountry()
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("countries.xml"));
foreach (XmlNode node in doc.SelectNodes("//country"))
{
usrlocationddl.Items.Add(new ListItem(node.InnerText, node.Attributes["codes"].InnerText));
}
}
The above code am using for loading countries ...
Hi!
I am trying to get along with WCF's duplex contracts. A code from this article
(http://msdn.microsoft.com/en-us/library/ms731184.aspx)
ICalculatorDuplexCallback callback = null;
callback = OperationContext.Current.GetCallbackChannel();
throws a NullReferenceException. So how can i manage this?
Thanks for your attention!
...
"Object reference not set to an instance of an object."
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace XNAdev
{
class Sprite
{
//The size of the Sprite
pu...
Hi!
Here is the server code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.ServiceModel.Description;
namespace Console_Chat
{
[ServiceContract(SessionMode = SessionMode.Required, CallbackContr...