nullreferenceexception

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

人盡茶涼 提交于 2019-12-23 07:39:00
问题 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? 回答1: It returns null because it is a shallow interface over the Java library. I think it sucks too, and I have been bitten by it. If you get a value that may be null, you can write Option(value) on Scala 2.8 and it will become either None or Some(value) . That doesn't work with pattern matching, but you can write your own

Null Object Reference Error [duplicate]

ε祈祈猫儿з 提交于 2019-12-23 06:12:59
问题 This question already has answers here : What is a NullReferenceException, and how do I fix it? (29 answers) Closed 4 years ago . I created a class like below public class Table { public enum ColumnNames { ID, TableName, Active, Date } public List<TableParameter> Parameters { get; set; } } public enum Types { INT, STRING, DATETIME, BOOLEAN, DECIMAL } public class TableParameter { public Table.ColumnNames ParameterName { get; set; } public Types? Tip { get; set; } public dynamic Value { get;

Entity Framework 5 Thread Agility

筅森魡賤 提交于 2019-12-22 09:55:28
问题 A NullReferenceException deep inside EntityFramework code is thrown (EF bug?), but my question is about Entity Framework (v5) and WebAPI asynchronous controller action. A repro would be hard to recreate here, but the code in essence does the following: public class AController : ApiController { private IUow _uow; //among other things, a DbContext // DI ctor public AController(IUow uow) { _uow = uow; } [HttpPost] public async Task<HttpResponseMessage> Post(Model model) { Entity e = _uow.Entity

Contains Query on multiple columns

时光总嘲笑我的痴心妄想 提交于 2019-12-22 08:37:07
问题 How do I search multiple columns using LINQ to SQL when any one of the column could be null? IEnumerable<User> users = from user in databaseUsers where user.ScreenName.Contains(search) || user.FirstName.Contains(search) || user.LastName.Contains(search) select user; I keep getting this exception: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information

NullReferenceException was unhandled by user code - Object reference not set to instance of an object [duplicate]

岁酱吖の 提交于 2019-12-22 05:57:11
问题 This question already has answers here : What is a NullReferenceException, and how do I fix it? (29 answers) Closed 5 years ago . I have the following C# classes: public class Locales { public Region region { get; set; } public Buttons buttons { get; set; } public Fields fields { get; set; } } public class Region { public Center center { get; set; } public East east { get; set; } } public class Center { public string title { get; set; } } public class East { public string title { get; set; }

NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust)

自古美人都是妖i 提交于 2019-12-20 10:37:34
问题 It seems like NLog can't use reflection for GetCurrentClassLogger() , even though my MVC 3 app is deployed in a Full Trust environment on IIS7. I'm using StructureMap 2.6.1 and the problem seems to appear sporadically between deploys. I can't figure out why, though I don't think StructureMap is causing it. Bootstrapper class: public static class Bootstrapper { public static void ConfigureStructureMap() { ObjectFactory.Initialize(Init); } private static void Init(IInitializationExpression x) {

Null Reference exception in C#

谁说胖子不能爱 提交于 2019-12-20 04:34:24
问题 I'm experiencing "null reference exception" when I'm attempting to return a value from a structure. here is the code: AssetItem item = new AssetItem(); item = initModified(); bool found = false; int index = getIndex(barcode); string modifiedFile = filepath + "Modified\\" + dir + "\\" + index + ".asdt"; if(File.Exists(modifiedFile)) { using(StreamReader reader = new StreamReader(modifiedFile)) { string line = reader.ReadLine(); while(line.Trim()!="") { string[] split = line.Split(','); if

Why Collection Initialization Throws NullReferenceException

僤鯓⒐⒋嵵緔 提交于 2019-12-20 02:13:21
问题 The following code throws a NullReferenceException : internal class Foo { public Collection<string> Items { get; set; } // or List<string> } class Program { static void Main(string[] args) { new Foo() { Items = { "foo" } // throws NullReferenceException }; } } Why don't collection initiliazers work in this case, although Collection<string> implements the Add() method, and why is NullReferenceException is thrown? Is it possible to get the collection initializer working, or is Items = new

NullReferenceException during C++ callback to C# function

杀马特。学长 韩版系。学妹 提交于 2019-12-19 17:42:03
问题 developers! I have very strange problem. My project has DLL writen in C++ and a GUI writen in C#. And I have implemented callback for some interoperability. I planed that C++ dll will call C# code in some circumstances. It works... but not long and I cant understand why. The problem marked in comment in C# part Here the complete code of simplified sample: C++ DLL: #include <SDKDDKVer.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason

how to get the store in a component in ember.js

老子叫甜甜 提交于 2019-12-19 17:39:32
问题 How in the world do i get a handle on the store inside of a component? I'm trying to create an auto-complete component that returns results from the store. App.AutoCompleteComponent = Ember.Component.extend({ //------------------------------------------- // Ember Properites //------------------------------------------- content: Ember.ArrayController.create(), //------------------------------------------- // Instance Properties //------------------------------------------- queryText: "",