Search Results

Search found 266 results on 11 pages for 'nullreferenceexception'.

Page 2/11 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • [LINQ]InsertOnSubmit NullReferenceException

    - by Kurresmack
    Hello, I have a rather annoying issue with LinqToSql. I have created a class that is derived from the class in the DataContext. The problem is that as soon as I use "InsertOnSubmit(this);" on this derived class I get a NullReferenceException. I've seen some people with the same issue. However they've used a custom constructor and solved the issue by calling ": this()" like this thread http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/0cf1fccb-6398-4f16-920b-adef9dc4ac9f The difference is that I use a default constructor which causes the base constructor to be called so there should not be any problem! Could someone please help me with this, starts to get annoying! Thanks :)

    Read the article

  • F# Silverlight 3.0 Custom Control Property throws: NullReferenceException

    - by akaphenom
    A new issue since my previous post. I am having some issues with the properties of the control in my Control Class I havse defined: static member ItemsProperty : DependencyProperty = DependencyProperty.Register( "Items", typeof<MyMenuItemCollection>, typeof<MyMenu>, null); member this.Items with get () : MyMenuItemCollection = this.GetValue(MyMenu.ItemsProperty) :?> MyMenuItemCollection and set (value: MyMenuItemCollection) = this.SetValue(MyMenu.ItemsProperty, value); The problem occurs on access: for menuItem in this.Items do let contentElement: FrameworkElement = menuItem.Content where I get a null referce exception on this.Items; 'Items' threw an exception of type 'System.NullReferenceException' Immediately after I initialized in the constructor: do this.Items <- new CoolMenuItemCollection()

    Read the article

  • DynamicMethod NullReferenceException

    - by Jeff
    Can anyone tell me what's wrong with my IL code here? IL_0000: nop IL_0001: ldarg.1 IL_0002: isinst MyXmlWriter IL_0007: stloc.0 IL_0008: ldloc.0 IL_0009: ldarg.2 IL_000a: ldind.ref IL_000b: unbox.any TestEnum IL_0010: ldfld Int64 value__/FastSerializer.TestEnum IL_0015: callvirt Void WriteValue(Int64)/System.Xml.XmlWriter IL_001a: nop IL_001b: ret I'm going crazy here, since I've written a test app which does the same thing as above, but in C#, and in reflector the IL code from that looks just like my DynamicMethod's IL code above (except my test C# app uses a TestStruct with a public field instead of the private value field on the enum above, but I have skipVisibility set to true)... I get a NullReferenceException. My DynamicMethod's signature is: public delegate void DynamicWrite(IMyXmlWriter writer, ref object value, MyContract contract); And I'm definitely not passing in anything null. Thanks in advance!

    Read the article

  • linq NullReferenceException while checking for null reference

    - by Odrade
    I have the following LINQ query: List<FileInputItem> inputList = GetInputList(); var results = from FileInputItem f in inputList where ( Path.GetDirectoryName(f.Folder).ToLower().Trim() == somePath || Path.GetDirectoryName(f.Folder).ToLower().Trim() == someOtherPath ) && f.Expression == null select f; Every time this query is executed, it generates a NullReferenceException. If I remove the condition f.Expression == null or change it to f.Expression != null, the query executes normally (giving the wrong results, of course). The relevant bits of FileInputItem look like this: [Serializable] public class FileInputItem { [XmlElement("Folder")] public string Folder { get; set; } [XmlElement("Expression")] public string Expression { get; set; } /*SNIP. Irrelevant properties */ } I'm new to LINQ to objects, so I'm probably missing something fundamental here. What's the deal?

    Read the article

  • System.NullReferenceException with WhoCanHelpMe Unit Test

    - by tlum
    I'm working with a test project based on WhoCanHelpMe, which is based on Sharp Architecture, NHibernateValidator, etc. As its written the when_the_profile_tasks_is_asked_to_create_a_profile unit test creates the profile object and saves it without issue. Now the profile object is a CreateProfileDetails type that derives from their own ValidatableValueObject which inherits the IValidatable interface. The problem surfaces when my class is based on an Entity rather than their ValidatableValueObject. When the test is run a System.NullReferenceException because Validate() is null. I'm afraid that I'm at a loss to resolve this bad behavior. Does anyone have some suggestions to get to the bottom of this? Thanks, -Ted-

    Read the article

  • Getting a NullReferenceException Error when invoking a Select File Dialog Box

    - by codingguy3000
    Hey everyone This is a real newbie question. I have simple app that selects a picture and display's that picture in a PictureBox. I decided to mess with the Opacity Attribute so I added a timer and created this cool effect where the Main Form's Opacity is increased by 20% every 400 miliseconds. The problem is that now when I click the button that invokes the Select File Dialog Box I'm getting a NullReferenceException error. private void tmrClock_Tick(object sender, EventArgs e) { if (ViewerForm.ActiveForm.Opacity != 1) { ActiveForm.Opacity = ActiveForm.Opacity + .20; } } The error message is pointing to the if statement. What am I doing wrong? Thanks

    Read the article

  • db4o Replication System: NullReferenceException?

    - by virtualmic
    Hi, I am trying to do standard bi-directional replication as follows. However, I get a NullReferenceException. This is a separate replication project. I did import the classes involved in the original project (such as Item, Category etc.) in this replication project. What am I doing wrong? (If I debug using VS, I can see that changedObjects does have all the changed objects; there seems to be some problem inside Replicate function) IObjectContainer local = Db4oFactory.OpenFile(@"G:\Work\School\MIS\VINMIS\Inventory\bin\Debug\vin.db4o"); IObjectContainer far = Db4oFactory.OpenFile(@"\\crs-lap\c$\vinmis\vin.db4o"); ; IReplicationSession replication = Replication.Begin(local, far); IObjectSet changedObjects = replication.ProviderA().ObjectsChangedSinceLastReplication(); while(changedObjects.HasNext()) replication.Replicate(changedObjects.Next()); // Exception!!! replication.Commit(); changedObjects = replication.ProviderB().ObjectsChangedSinceLastReplication(); while (changedObjects.HasNext()) replication.Replicate(changedObjects.Next()); replication.Commit(); Regards, Saurabh.

    Read the article

  • InsertOnSubmit - NullReferenceException

    - by Jackie Chou
    I have 2 Model AccountEntity [Table(Name = "Account")] public class AccountEntity { [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public int id { get; set; } [Column(CanBeNull = false, Name = "email")] public string email { get; set; } [Column(CanBeNull = false, Name = "pwd")] public string pwd { get; set; } [Column(CanBeNull = false, Name = "row_guid")] public Guid guid { get; set; } private EntitySet<DetailsEntity> details_id { get; set; } [Association(Storage = "details_id", OtherKey = "id", ThisKey = "id")] public ICollection<DetailsEntity> detailsCollection { get; set; } } DetailsEntity [Table(Name = "Details")] public class DetailsEntity { public DetailsEntity(AccountEntity a) { this.Account = a; } [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "int")] public int id { get; set; } private EntityRef<AccountEntity> _account = new EntityRef<AccountEntity>(); [Association(IsForeignKey = true, Storage = "_account", ThisKey = "id")] public AccountEntity Account { get; set; } } Main using (Database db = new Database()) { AccountEntity a = new AccountEntity(); a.email = "hahaha"; a.pwd = "13212312"; a.guid = Guid.NewGuid(); db.Account.InsertOnSubmit(a); db.SubmitChanges(); } that has relationhip AccountEntity <- DetailsEntity (1-n) when i'm trying to insert a record exception throws NullReferenceException cause: by EntitySet null please help me make it insert

    Read the article

  • Mocking HtmlHelper throws NullReferenceException

    - by Matt Austin
    I know that there are a few questions on StackOverflow on this topic but I haven't been able to get any of the suggestions to work for me. I've been banging my head against this for two days now so its time to ask for help... The following code snippit is a simplified unit test to demonstrate what I'm trying to do, which is basically call RadioButtonFor in the Microsoft.Web.Mvc assembly in a unit test. var model = new SendMessageModel { SendMessageType = SendMessageType.Member }; var vd = new ViewDataDictionary(model); vd.TemplateInfo = new TemplateInfo { HtmlFieldPrefix = string.Empty }; var controllerContext = new ControllerContext(new Mock<HttpContextBase>().Object, new RouteData(), new Mock<ControllerBase>().Object); var viewContext = new Mock<ViewContext>(new object[] { controllerContext, new Mock<IView>().Object, vd, new TempDataDictionary(), new Mock<TextWriter>().Object }); viewContext.Setup(v => v.View).Returns(new Mock<IView>().Object); viewContext.Setup(v => v.ViewData).Returns(vd).Callback(() => {throw new Exception("ViewData extracted");}); viewContext.Setup(v => v.TempData).Returns(new TempDataDictionary()); viewContext.Setup(v => v.Writer).Returns(new Mock<TextWriter>().Object); viewContext.Setup(v => v.RouteData).Returns(new RouteData()); viewContext.Setup(v => v.HttpContext).Returns(new Mock<HttpContextBase>().Object); viewContext.Setup(v => v.Controller).Returns(new Mock<ControllerBase>().Object); viewContext.Setup(v => v.FormContext).Returns(new FormContext()); var mockContainer = new Mock<IViewDataContainer>(); mockContainer.Setup(x => x.ViewData).Returns(vd); var helper = new HtmlHelper<ISendMessageModel>(viewContext.Object, mockContainer.Object, new RouteCollection()); helper.RadioButtonFor(m => m.SendMessageType, "Member", cssClass: "selector"); If I remove the cssClass parameter then the code works ok but fails consistently when adding additional parameters. I've tried every combination of mocking, instantiating concrete types and using fakes that I can think off but I always get a NullReferenceException when I call RadioButtonFor. Any help hugely appreciated!!

    Read the article

  • NullReferenceException at Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem[] R

    - by Eugene Larchick
    Hi, I updated my Visual Studio 2010 to the version 10.0.30319.1 RTM Rel and start getting the following exception during the build: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem[] ReferenceAssemblies) at Microsoft.Silverlight.Build.Tasks.CompileXaml.get_GetXamlSchemaContext() at Microsoft.Silverlight.Build.Tasks.CompileXaml.GenerateCode(ITaskItem item, Boolean isApplication) at Microsoft.Silverlight.Build.Tasks.CompileXaml.Execute() at Bohr.Silverlight.BuildTasks.BohrCompileXaml.Execute() The code of BohrCompileXaml.Execute is the following: public override bool Execute() { List<TaskItem> pages = new List<TaskItem>(); foreach (ITaskItem item in SilverlightPages) { string newFileName = getGeneratedName(item.ItemSpec); String content = File.ReadAllText(item.ItemSpec); String parentClassName = getParentClassName(content); if (null != parentClassName) { content = content.Replace("<UserControl", "<" + parentClassName); content = content.Replace("</UserControl>", "</" + parentClassName + ">"); content = content.Replace("bohr:ParentClass=\"" + parentClassName + "\"", ""); } File.WriteAllText(newFileName, content); pages.Add(new TaskItem(newFileName)); } if (null != SilverlightApplications) { foreach (ITaskItem item in SilverlightApplications) { Log.LogMessage(MessageImportance.High, "Application: " + item.ToString()); } } foreach (ITaskItem item in pages) { Log.LogMessage(MessageImportance.High, "newPage: " + item.ToString()); } CompileXaml xamlCompiler = new CompileXaml(); xamlCompiler.AssemblyName = AssemblyName; xamlCompiler.Language = Language; xamlCompiler.LanguageSourceExtension = LanguageSourceExtension; xamlCompiler.OutputPath = OutputPath; xamlCompiler.ProjectPath = ProjectPath; xamlCompiler.RootNamespace = RootNamespace; xamlCompiler.SilverlightApplications = SilverlightApplications; xamlCompiler.SilverlightPages = pages.ToArray(); xamlCompiler.TargetFrameworkDirectory = TargetFrameworkDirectory; xamlCompiler.TargetFrameworkSDKDirectory = TargetFrameworkSDKDirectory; xamlCompiler.BuildEngine = BuildEngine; bool result = xamlCompiler.Execute(); // HERE we got the error! And the definition of the task: <BohrCompileXaml LanguageSourceExtension="$(DefaultLanguageSourceExtension)" Language="$(Language)" SilverlightPages="@(Page)" SilverlightApplications="@(ApplicationDefinition)" ProjectPath="$(MSBuildProjectFullPath)" RootNamespace="$(RootNamespace)" AssemblyName="$(AssemblyName)" OutputPath="$(IntermediateOutputPath)" TargetFrameworkDirectory="$(TargetFrameworkDirectory)" TargetFrameworkSDKDirectory="$(TargetFrameworkSDKDirectory)" > <Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" /> <!-- Add to the list list of files written. It is used in Microsoft.Common.Targets to clean up for a next clean build --> <Output ItemName="FileWrites" TaskParameter="WrittenFiles" /> <Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" /> </BohrCompileXaml> What can be the reason? And how can I get more info what's happening inside CompileXaml class?

    Read the article

  • NullReferenceException when changing skin/theme via Application.Current.Resources

    - by CoolCat
    I am writing an wpf application with multiple skins. The code to switch theme is as below: try { Application.Current.Resources.MergedDictionaries.Add( resource ); } catch( Exception ex ) { } The first time the code is called (to switch to a new theme), it is executed successfully; however, any subsequent calls to the same code would throw System.NullReferenceException. The way I set up my themes are similar to what described here: http://www.codewrecks.com/blog/index.php/2008/05/22/simple-skinnable-and-theme-management-in-wpf-user-interface/. Has anyone seen this error before? How do I go about debugging this since the exception is thrown else where? Any help is greatly appreciated. StackTrace: at System.Windows.EffectiveValueEntry.GetFlattenedEntry(RequestFlags requests) at System.Windows.DependencyObject.EvaluateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry newEntry, OperationType operationType) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) at System.Windows.StyleHelper.ApplyStyleOrTemplateValue(FrameworkObject fo, DependencyProperty dp) at System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList`1& exclusionContainerDependents, FrugalStructList`1& oldContainerDependents, FrugalStructList`1& newContainerDependents) at System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle) at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache) at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp) at System.Windows.FrameworkElement.UpdateStyleProperty() at System.Windows.TreeWalkHelper.InvalidateStyleAndReferences(DependencyObject d, ResourcesChangeInfo info, Boolean containsTypeOfKey) at System.Windows.TreeWalkHelper.OnResourcesChanged(DependencyObject d, ResourcesChangeInfo info, Boolean raiseResourceChangedEvent) at System.Windows.TreeWalkHelper.OnResourcesChangedCallback(DependencyObject d, ResourcesChangeInfo info) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe) at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d) at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode) at System.Windows.TreeWalkHelper.InvalidateOnResourcesChange(FrameworkElement fe, FrameworkContentElement fce, ResourcesChangeInfo info) at System.Windows.Application.InvalidateResourceReferenceOnWindowCollection(WindowCollection wc, ResourcesChangeInfo info) at System.Windows.ResourceDictionary.NotifyOwners(ResourcesChangeInfo info) at System.Windows.ResourceDictionary.OnMergedDictionariesChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at System.Windows.ResourceDictionaryCollection.InsertItem(Int32 index, ResourceDictionary item) at System.Collections.ObjectModel.Collection`1.Add(T item)

    Read the article

  • VB.NET - Object reference not set to an instance of an object

    - by Daniel
    I need some help with my program. I get this error when I run my VB.NET program with a custom DayView control. ***** Exception Text ******* System.NullReferenceException: Object reference not set to an instance of an object. at SeaCow.Main.DayView1_ResolveAppointments(Object sender, ResolveAppointmentsEventArgs args) in C:\Users\Daniel\My Programs\Visual Basic\SeaCow\SeaCow\SeaCow\Main.vb:line 120 at Calendar.DayView.OnResolveAppointments(ResolveAppointmentsEventArgs args) at Calendar.DayView.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) According to the error code, the 'for each' loop below is causing the NullReferenceException error. At default, the 'appointments' list is assigned to nothing and I can't find where the ResolveAppointments function is being called at. Private Sub DayView1_ResolveAppointments(ByVal sender As Object, ByVal args As Calendar.ResolveAppointmentsEventArgs) Handles DayView1.ResolveAppointments Dim m_Apps As New List(Of Calendar.Appointment) For Each m_App As Calendar.Appointment In appointments If (m_App.StartDate >= args.StartDate) AndAlso (m_App.StartDate <= args.EndDate) Then m_Apps.Add(m_App) End If Next args.Appointments = m_Apps End Sub Anyone have any suggestions?

    Read the article

  • NullReferenceException when testing DefaultModelBinder.

    - by Byron Sommardahl
    I'm developing a project using BDD/TDD techniques and I'm trying my best to stay the course. A problem I just ran into is unit testing the DefaultModelBinder. I'm using mspec to write my tests. I have a class like this that I want to bind to: public class EmailMessageInput : IMessageInput { public object Recipient { get; set; } public string Body { get; set; } } Here's how I'm building my spec context. I'm building a fake form collection and stuffing it into a bindingContext object. public abstract class given_a_controller_with_valid_email_input : given_a_controller_context { Establish additional_context = () => { var form = new FormCollection { new NameValueCollection { { "EmailMessageInput.Recipient", "[email protected]"}, { "EmailMessageInput.Body", "Test body." } } }; _bindingContext = new ModelBindingContext { ModelName = "EmailMessageInput", ValueProvider = form }; _modelBinder = new DefaultModelBinder(); }; protected static ModelBindingContext _bindingContext; protected static DefaultModelBinder _modelBinder; } public abstract class given_a_controller_context { protected static MessageController _controller; Establish context = () => { _controller = new MessageController(); }; } Finally, my spec throws an null reference exception when I execute .BindModel() from inside one of my specs: Because of = () => { _model = _modelBinder.BindModel(_controller.ControllerContext, _bindingContext); }; Any clue what it could be? Feel free to ask me for more info, if needed. I might have taken something for granted.

    Read the article

  • Avoiding a NullReferenceException

    - by Nikhil K
    I have used this code for extracting urls from web page.But in the line of 'foreach' it is showing Object reference not set to an instance of an object exception. What is the problem? how can i correct that? WebClient client = new WebClient(); string url = "http://www.google.co.in/search?hl=en&q=java&start=10&sa=N"; string source = client.DownloadString(url); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(source); foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href and @rel='nofollow']")) { Console.WriteLine(link.Attributes["href"].Value); }

    Read the article

  • How can this code throw a NullReferenceException?

    - by Davy8
    I must be going out of my mind, because my unit tests are failing because the following code is throwing a null ref exception: int pid = 0; if (parentCategory != null) { Console.WriteLine(parentCategory.Id); pid = parentCategory.Id; } The line that's throwing it is: pid = parentCategory.Id; The console.writeline is just to debug in the NUnit GUI, but that outputs a valid int. Edit: It's single-threaded so it can't be assigned to null from some other thread, and the fact the the Console.WriteLine successfully prints out the value shows that it shouldn't throw. Edit: Relevant snippets of the Category class: public class Category { private readonly int id; public Category(Category parent, int id) { Parent = parent; parent.PerformIfNotNull(() => parent.subcategories.AddIfNew(this)); Name = string.Empty; this.id = id; } public int Id { get { return id; } } } Well if anyone wants to look at the full code, it's on Google Code at http://code.google.com/p/chefbook/source/checkout I think I'm going to try rebooting the computer... I've seen pretty weird things fixed by a reboot. Will update after reboot. Update: Mystery solved. Looks like NUnit shows the error line as the last successfully executed statement... Copy/pasted test into new console app and ran in VS showed that it was the line after the if statement block (not shown) that contained a null ref. Thanks for all the ideas everyone. +1 to everyone that answered.

    Read the article

  • Myself throwing NullReferenceException... needs help

    - by Amit Ranjan
    I know it might be a weird question and its Title too, but i need your help. I am a .net dev , working on platform for the last 1.5 years. I am bit confused on the term usually we say " A Good Programmer ". I dont know ,what are the qualities of a good programmer ? Is the guy who writes a bug free code? or Can develop applications solely? or blah blah blah...lots of points. I dont know... But as far i am concerned , I know I am not a good programmer, still in learning phase an needs a lot to learn in coming days. So you guys are requested to please help me with this two problems of mine My first problem is regarding the proper Error Handling, which is a most debatable aspect of programming. We all know we use ` try { } catch { } finally { } ` in our code to manage exception. But even if I use try { } catch(exception ex) { throw ex } finally { } , different guys have different views. I still dont know the good way to handle errors. I can write code, use try-catch but still i feel I lacks something. When I saw the codes generated by .net fx tools even they uses throw ex or `throw new Exception("this is my exception")`.. I am just wondering what will be the best way to achieve the above. All means the same thing but why we avoid something. If it has some demerits then it must be made obselete.Anyways I still dont have one [how to handle errors efficiently?]. I generally follow the try-catch(execoption ex){throw ex}, and usually got stucked in debates with leads why you follow this why not that... 2.Converting your entire code blocks in modules using Design patterns of some OOPs concepts. How do you guys decide what architeture or pattern will be the best for my upcoming application based on its working, flow etc. I need to know what you guys can see that I can't. Since I know , I dont have that much experience but I can say, with my experience that experience doesnot comes either from degree/certificates or success you made instead it cames from failures you faced or got stucking situations. Pleas help me out.

    Read the article

  • Serialport List Read problem and NullReferenceException?

    - by Plumbum7
    Hello everybody, Using Microsoft VC# 2008 Express (little fact about me : non experience in c#, programskills further very beginnerlevel. This peace op program is to communicate with Zigbee switching walloutlets (switching, status info). and is downloaded from http://plugwiselib.codeplex.com/SourceControl/list/changesets The problem: NullRefferenceException was UnHandled private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) {// Event for receiving data string txt = port.ReadExisting(); Console.WriteLine(txt); List<PlugwiseMessage> msg = reader.Read (Regex.Split (txt, "\r\n" )); //Console.WriteLine( msg ); DataReceived(sender, new System.EventArgs(), msg); VC# Marks the last line and says msg is empty. so i looked further. Msg come's from txt text is filled with "000002D200C133E1\r\nPutFifoUnicast 40 : Handle 722 :"< so it goes wrong in or reader.Read or in the List so i looked further: public List<PlugwiseMessage> Read(string[] serialData) { Console.WriteLine(serialData); List<PlugwiseMessage> output = new List<PlugwiseMessage>(); Console.WriteLine(output); Both (serialData) as (output); are empty. So can i assume that the problem is in: Read(string[] serialData) But now the questions, Is Read(string[] serialData) something which is a Windows.Refence or is is from a Method ? and IF this is so is this then reader.READ (how can i find this)? (answered my own question proberly)(method reader)(private PlugwiseReader reader) So why isn't is working trough the serialData ? or is it the List<PlugwiseMessage> part, but i have no idea how it is filled can sombody help me ?

    Read the article

  • can ServiceLocator.Current.GetInstance return null?

    - by mauricio076
    I have this piece of code (or similar) in many of our views: private IEventAggregator eventAggregator; Constructor() { eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); ... } I read from this post that ServiceLocator.Current can throw NullReferenceException (bad thing on a constructor) but I was wondering if the GetInstance<() method can return null (or some other inconsistent object) making eventAggregator dangerous to use later in other methods. NOTE: I'm quite new to MVVM and WPF

    Read the article

  • Why would an error get thrown inside my try-catch?

    - by George Johnston
    Why would my try-catch block still be throwing an error when it's handled? Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Try Here >> : _MemoryStream.Seek(6 * StartOffset, 0) _MemoryStream.Read(_Buffer, 0, 6) Catch ex As IOException // Handle Error End Try Edit: Cleaned the question up to remove the extraneous information.

    Read the article

  • Null Reference Exception on MVVM pattern

    - by Mohit Deshpande
    System.NullReferenceException Object reference not set to an instance of an object. at Microsoft.Windows.Design.DocumentModel.Trees.MarkupDocumentTreeManager.<FindMarkupNodePath>d__0.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at MS.Internal.Services.DocumentInformationServiceImpl.get_Root() at MS.Internal.Designer.VSDesigner.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView() I keep getting this exception and then intellisense stops working in a XAML text editor. Any ideas why?

    Read the article

  • Why would a error get thrown inside my try-catch?

    - by George Johnston
    I'm pushing a copy of our application over to a new dev server (IIS7) and the application is blowing up on a line inside of a try-catch block. It doesn't happen locally, it actually obey's the rules of a try-catch block, go figure. Any idea why this would be happening? Shouldn't it just be failing silently? Is there something environmental I need to enable/disable? Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Line 229: Try Line 230: Here >> : _MemoryStream.Seek(6 * StartOffset, 0) Line 232: _MemoryStream.Read(_Buffer, 0, 6) Line 233: Catch ex As IOException End Try Although it doesn't matter for answering this question, I thought I would mention that it's third party code for the Geo IP lookup.

    Read the article

  • Dynamically created "CheckBoxList" in placeholder controls throwing null reference exception error d

    - by newName
    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 page will show the error "System.NullReferenceException". the following code is written in Page_Load in (!Page.IsNotPostBack) and in a loop that will dynamically create a number of checkboxlist: CheckBoxLis chkContent = new CheckBoxList(); chkContent.ID = chkIDString; //chkIDString is an incremental int based on the row count chkContent.RepeatDirection = RepeatDirection.Horizontal; foreach (List<t> contentList in List<t>) //data retrieved as List<t> using LINQ { ListItem contents = new ListItem(); contents.Text = contentList.Title; contents.Value = contentList.contentID.ToString(); chkContent.Items.Add(contents); } plcSchool.Controls.Add(chkContent); //plcSchool is my placeholder plcSchool.Controls.Add(new LiteralControl("<br>")); protected void btnAdd_Click(object sender, EventArgs e) { CheckBoxList cbl = Page.FindControl("chkContent4") as CheckBoxList; Response.Write(cbl.SelectedValue.ToString()); // now im just testing to get the value from one of the checkboxlist } Anyone able to help, as it seems the controls are not recreated after the postback, therefore it can't find the control and throwing the null reference exception.

    Read the article

  • How to get interpolated message in NHibernate.Validator

    - by SztupY
    Hi! I'm trying to integrate NHibernate.Validator with ASP.NET MVC client side validations, and the only problem I found is that I simply can't convert the non-interpolated message to a human-readable one. I thought this would be an easy task, but turned out to be the hardest part of the client-side validation. The main problem is that because it's not server-side, I actually only need the validation attributes that are being used, and I don't actually have an instance or anything else at hand. Here are some excerpts from what I've been already trying: // Get the the default Message Interpolator from the Engine IMessageInterpolator interp = _engine.Interpolator; if (interp == null) { // It is null?? Oh, try to create a new one interp = new NHibernate.Validator.Interpolator.DefaultMessageInterpolator(); } // We need an instance of the object that needs to be validated, se we have to create one object instance = Activator.CreateInstance(Metadata.ContainerType); // we enumerate all attributes of the property. For example we have found a PatternAttribute var a = attr as PatternAttribute; // it seems that the default message interpolator doesn't work, unless initialized if (interp is NHibernate.Validator.Interpolator.DefaultMessageInterpolator) { (interp as NHibernate.Validator.Interpolator.DefaultMessageInterpolator).Initialize(a); } // but even after it is initialized the following will throw a NullReferenceException, although all of the parameters are specified, and they are not null (except for the properties of the instance, which are all null, but this can't be changed) var message = interp.Interpolate(new InterpolationInfo(Metadata.ContainerType, instance, PropertyName, a, interp, a.Message)); I know that the above is a fairly complex code for a seemingly simple question, but I'm still stuck without solution. Is there any way to get the interpolated string out of NHValidator?

    Read the article

  • Object reference not set to an instance of an object.

    - by Lambo
    I have the following code - private static void convert() { string csv = File.ReadAllText("test.csv"); string year = "2008"; XDocument doc = ConvertCsvToXML(csv, new[] { "," }); doc.Save("update.xml"); XmlTextReader reader = new XmlTextReader("update.xml"); XmlDocument testDoc = new XmlDocument(); testDoc.Load(@"update.xml"); XDocument turnip = XDocument.Load("update.xml"); webservice.singleSummary[] test = new webservice.singleSummary[1]; webservice.FinanceFeed CallWebService = new webservice.FinanceFeed(); foreach(XElement el in turnip.Descendants("row")) { test[0].account = el.Descendants("var").Where(x => (string)x.Attribute("name") == "account").SingleOrDefault().Attribute("value").Value; test[0].actual = System.Convert.ToInt32(el.Descendants("var").Where(x => (string)x.Attribute("name") == "actual").SingleOrDefault().Attribute("value").Value); test[0].commitment = System.Convert.ToInt32(el.Descendants("var").Where(x => (string)x.Attribute("name") == "commitment").SingleOrDefault().Attribute("value").Value); test[0].costCentre = el.Descendants("var").Where(x => (string)x.Attribute("name") == "costCentre").SingleOrDefault().Attribute("value").Value; test[0].internalCostCentre = el.Descendants("var").Where(x => (string)x.Attribute("name") == "internalCostCentre").SingleOrDefault().Attribute("value").Value; MessageBox.Show(test[0].account, "Account"); MessageBox.Show(System.Convert.ToString(test[0].actual), "Actual"); MessageBox.Show(System.Convert.ToString(test[0].commitment), "Commitment"); MessageBox.Show(test[0].costCentre, "Cost Centre"); MessageBox.Show(test[0].internalCostCentre, "Internal Cost Centre"); CallWebService.updateFeedStatus(test, year); } It is coming up with the error of - NullReferenceException was unhandled, saying that the object reference not set to an instance of an object. The error occurs on the first line test[0].account. How can I get past this?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >