How do I fix this?
Object reference not set to an instance of an object.
at Change_Request.FormCode.FormEvents_OnSubmitRequest(DocReturnEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSubmitRequest(DocReturnEvent pEvent)
try running the form in full trust. looks like you have a permission's issue.
Related
This is an asp.net-mvc application and I am trying to add an object, specifically a list of user objects to the cache. I feel like I'm missing a key concept or component when it comes to caching data, so any help would be greatly appreciated.
var cache = new Cache();
cache["Users"] = users;
The second line throw's "Object reference not set to an instance of an object. The users variable is not null, I'm certain I'm not creating or using the cache correctly, but cannot find any information in MSDN or SO regarding the right way to set up a cache. What's my mistake?
try using Cache Like this it may works if you are using static methods
System.Web.HttpContext.Current.Cache
I have a frustrating issue when trying to pass a custom object from 1 page of a web site to another. When I try to use the object from session on the page 2 it is null. I believe that my syntax is correct as when I take the code out of my larger solution and run it on it's own it works fine.
I am wondering if there are any settings in visual studio, aspx files, project properties that may be set on my project that may be causing this session object not to work?
Simplied syntax that I am using is;
on page1
Person p = new Person;
p.name = "john";
p.secondName = "doe";
Session["person"] = p.
Response.Redirect("Page2.aspx")
Page 2 on page load method
Person p = (person)Session["person"]
textbox1.Text = p.name;
textbox2.Text = p.Secondname;
As I said this code works fine on it's own but not as part of my larger works project. Any ideas on why this may not be working would be greatly appreciated
There are three possible options.
First one is that inside your larger project session state is disabled. Please visit Turn Off ASP Session State in Active Server Pages and IIS for more details.
Second option would be that exception occurs somewhere inside your application (separate thread) resulting in application restart and session state loose. You can check this by hooking to Application error inside Global.asax like this:
void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
}
The last option would be that session["person"] value is changed in other module or page.
Try code with,
Response.Redirect("Page2.aspx", false);
See as per your code if there is database connected then i suggest you to do whatever you want to on page1 and save it to db in single or multiple tables, depending upon the requirements. Now paas the id to page2 as querystring. Format looks like
Response.Redirect("~/page2.aspx?id=67");
where is the dynamic unique id from database. Now on page 2.aspx query on the id you have passed.
In my SharePoint code, I have the following line:
SPWeb web = site.RootWeb; //site is an SPSite object
When I rebuild my project and run the SPDispose tool on the assembly, I get the following error:
Module: Blah.SharePoint.Features.Core.dll Method:
Blah.SharePoint.Features.Core.Helpers.FeatureDeploymentHelper.RemoveWebPartFiles(Microsoft.SharePoint.SPFeatureReceiverProperties,System.String)
Statement: web := site.{Microsoft.SharePoint.SPSite}get_RootWeb()
Source:
C:\xxx\xxx\Main\Source\SharePoint\Features\Core\Helpers\FeatureDeploymentHelper.cs
Line: 26
Notes: Disposable type not disposed: Microsoft.SharePoint.SPWeb
***This may be a false positive depending on how the type was created or if it is disposed outside the current scope More Information:
http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_140
What I want to do is to have the SPDispose tool ignore this error, so I have pulled the SPDisposeCheckIgnore class and supporting enum into my project, and I've decorated my method appropriately:
[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_140, "RootWeb does not need disposed.")]
public static void RemoveWebPartFiles(SPFeatureReceiverProperties properties, string assemblyName)
{
...
}
After doing all of this, I still receive the error. Anyone know how I might go about getting rid of that error?
Two things need to be done here.
1) The SPDisposeCheckIgnore class must be defined in the SPDisposeCheck namespace. You CANNOT have your own namespace. See the related comment on this page: http://archive.msdn.microsoft.com/SPDisposeCheck/
2) Anything you are trying to ignore within RunWithElevatedPrivleges must be pulled into an external method or it will not be recognized. This was not being done in the example above, but was being done in other places.
These two rules must be followed for ignore to work. Hope this helps someone else down the road.
Double check how you're retrieving and assigning the RootWeb object. If it's done in an external method, the DisposeChecker might not pick up that it's a RootWeb reference.
I don't see anything wrong with what you've written. I pulled out getting the root web into a static method so I only had to ignore this error in one place, and it works in anonymous delegates. The following worked for me:
public class DisposeUtils
{
[SPDisposeCheckIgnore(SPDisposeCheckID.SPDisposeCheckID_140, "RootWeb does not need disposed. http://blogs.msdn.com/b/rogerla/archive/2009/11/30/sharepoint-2007-2010-do-not-dispose-guidance-spdisposecheck.aspx")]
public static SPWeb GetRootWeb(SPSite site)
{
return site.RootWeb;
}
}
Sorry, I'm not sure if that helps exactly - I'm saying your code should work. Have you checked SPDisposeCheck to see how it handles 'Documented' and 'Undocumented' errors? (I've never been entirely clear what those settings do)
I got a master page with a server control in it. Randomly the server control is inaccessible from codebehind. This doesn't happen on a specific action (eg a Button click or so). Currently I have no clue what this could be. I don't think it's output caching since this is not explcitly activated and the error happens far to seldom for that. But I'm going to disable caching in the master page explicitly with next deployment.
Anyone an idea how to find more info to find what's happening? Or has someone had a similar error?
The control is defined in markup. The accompaning codebehind is:
PGFMainNavi.HasAccessToFunction = HasAccessToNaviItem;
// HasAccessToNavi is a local function
Exception is:
System.NullReferenceException: Object reference not set to an instance
of an object
Thanks.
sa
I have similar errors when I cache my controls - and I always check if their null, or if they are the correct types.
I think that your control is cached somewhere.
Use this code, to check that is not cached.
if(PGFMainNavi != null)
{
PGFMainNavi.HasAccessToFunction = HasAccessToNaviItem;
}
or find where you set the case on this control and remove it.
Second Solution
Some times after an online update I get this error, because compiler did fail to read correct all involving files - probably some user read the page the same time I copy the files or something.
To avoid that I always use the app_offline.htm before make my updates.
I have a VB.NET site. At the top of many of my pages I have code such as this:
Partial Class _Default
Inherits System.Web.UI.Page
Dim fns As New Functions
Dim bOnOff As Boolean
Dim LNBs As New LimsNetBusiness.SiteUI.SiteUI
Dim LNBu As New LimsNetBusiness.User.user
Dim LNBp As New LimsNetBusiness.PasswordFunctions.Password
When I publish the site. I get "Object reference not set to an instance of an object." on line:
Dim LNBs As New LimsNetBusiness.SiteUI.SiteUI
Why? And how do I fix?
You would need to show us the constructor of LimsNetBusiness.SiteUI.SiteUI I would assume.
Given that this problem only happens remotely, I'm thinking the constructor accesses an asset, connection or config file that isn't available on the server.
My recommendation is to open the DLL with Reflector and see what resources it accesses/other potentials for a null dereference.
Oddly you are saying there is no Sub New(), but I'm curious how you can create a variable of that type without having a constructor.
You mention that SiteUI passes through to your data layer - are you confident the data layer access is working fine remotely?
Not enough info. Unfortunately LimsNetBusiness is not a .net namespace. I would suggest looking into the SiteUI constructor and see if you fail inside there.
Is LimsNetBusiness a seperate DLL? Did you publish that too?
Does LimsNetBusiness.SiteUI.SiteUI reference a table, or perhaps web.config file? Maybe a table row was deleted or something similar.
This is a NullReferenceException Some where along the way a NullReferenceException is occurring.
Now you didn't provide enough information about what LimsNetBusiness is but if I had to guess:
Since I can't see you stack trace, you should be aware of the fact that the exception might be contained in the code that is instantiated in the constructor of LimsNetBusiness.SiteUI.SiteUI
If LimsNetBusiness.SiteUI is a static Property, you will need to make sure that you instantiate the returned object.
It's possible that the error is occuring in the initialization of LNBs. Since that happens in the dim statement, you probably won't see the location of the error if this is true. You can try moving the initialization of LNBs to an assignment statement:
Dim LNBs As LimsNetBusiness.SiteUI.SiteUI
LNBs = new LimsNetBusiness.SiteUI.SiteUI
Also, check in the initialization of LimsNetBusiness.SiteUI.SiteUI and make sure there is a "new" everywhere that there should be.