nullreferenceexception

Null reference exception when generating a url with UrlHelper.Action method

拈花ヽ惹草 提交于 2019-12-03 10:14:23
For some reason, when certain bots visit the site, generating a url with the UrlHelper.Action method raises a null exception from System.Web.HttpServerVarsCollection.Get . I've done some debugging and the call stack originiates with an attempt to get the 'HTTP_X_ORIGINAL_URL' from the HttpContextBase.Request.ServerVariables collection. If I visit the same address directly from a browser - no problem. The page is server and no error is logged. It only seems to occur when visited by a bot. Not sure if it's relevant or not, but the site was just migrated to IIS 7.5. Still using .NET 2.0 in

NullReferenceException when doing InsertOnSubmit in LINQ to SQL

陌路散爱 提交于 2019-12-03 08:22:00
问题 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 an abstract class and interface to make sure some other properties are also implemented. Now when I create a new instance of "StaffMember" eg. StaffMember

NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust)

只愿长相守 提交于 2019-12-02 23:34:14
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) { x.AddRegistry(new DBServiceRegistry()); x.AddRegistry(new MyRegistry()); } } Registry class: public

async await Task null reference exception

泪湿孤枕 提交于 2019-12-02 14:53:06
问题 I am getting NullReferenceExceptions on a webforms project I'm maintaining. The catch is that there is no stacktrace for this exception because none of my code causes the exception. Exception details copied to the clipboard offers zero assistance: System.NullReferenceException was unhandled Message: An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll Additional information: Object reference not set to an instance of an object. When I view the non-user code

System.NullReferenceException: Object reference not set to an instance of an object [duplicate]

我与影子孤独终老i 提交于 2019-12-02 14:51:34
Possible Duplicate: System.NullReferenceException: Object reference not set to an instance of an object look at my code if (ViewState["Edit"].ToString() == "new") { } else { row = _section.GetBannerEntry(ViewState["Edit"].ToString()); } I was getting the error on this line if (ViewState["Edit"].ToString() == "new") I replaced with if (ViewState["Edit"] != null && ViewState["Edit"].ToString() == "new") it works. Now I am getting the same error here in else row = _section.GetBannerEntry(ViewState["Edit"].ToString()); please help Bindas Your View state is null Check for if(ViewState["Edit"]!=

NullReferenceException when running published website in IIS

好久不见. 提交于 2019-12-02 11:25:33
I have a website that I published before adding it in IIS. After that I set the published website as the default website in IIS. I got an error that the "Object reference is not set to the instance of an object" when I inserted values through form. There is no issues when the website is running in IIS without publishing. The error occurs when values are inserted using datagrid. The error messages is as follows: Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request.

NullReferenceException WIA C#

为君一笑 提交于 2019-12-02 10:47:47
When I run the code below I get this error NullreferenceException was unhandled.. below is my code private void showScannerDialog() { this.scanner = null; this.imageItem = null; this.getScanner(); WIA.CommonDialog dialog = new WIA.CommonDialog(); Items imageItems = dialog.ShowSelectItems(this.scanner, WiaImageIntent.TextIntent, WiaImageBias.MinimizeSize, false, true, false); if (imageItems != null) { foreach (Item item in imageItems) { imageItem = item; break; } } } thanks // complete code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using

using DropdownlistFor helper for a list of names

ε祈祈猫儿з 提交于 2019-12-02 09:25:26
问题 I know it was silly to ask this question but I'm not able to figure it out and I need your help guys. First of all I am new to MVC. In my Project I am using a dropdownlistFor helper for displaying a list of names available for a particular Id. I did that and it is displaying names for an id. Now while posting the form I am getting a Null Reference Exception for property used in the dropdownlist. Here is my property in model which is a list of names. In my controller in the [HttpGet] I did

NullReferenceException in F#

一曲冷凌霜 提交于 2019-12-02 08:27:14
问题 When I step through the following code, report on the second line is null. However, the third line generates a NullReferenceException. member this.setTaggedResearchReportList (index : int) (taggedResearchReport : TaggedResearchReportUIVO option) = let report = Option.get(taggedResearchReport) if not(report.Equals(null)) then // do some stuff here Why is that, and what can I do to avoid it? Thanks! Added later: Here's the line that calls this.setTaggedResearchReportList :

async await Task null reference exception

折月煮酒 提交于 2019-12-02 08:27:08
I am getting NullReferenceExceptions on a webforms project I'm maintaining. The catch is that there is no stacktrace for this exception because none of my code causes the exception. Exception details copied to the clipboard offers zero assistance: System.NullReferenceException was unhandled Message: An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll Additional information: Object reference not set to an instance of an object. When I view the non-user code stacktrace, I see the following (all in mscorlib): The error occurs randomly and inconsistently, either