Set static or instance on level of methods in class?
Hi,
Can anyone tell me to set the level of method in class, which is better, static or instance?Because if set static, I don't need to create instance for a class, but I don't know it's advantage and disadvantage.
Hi,
There is no rule, it depends on your requirement. Usually you create STATIC methods for UTILITY classes like CL_GUI_FRONTEND_SERVICES or MATHS functions.
If its dependent on a business object, then it makes sense for a instance method, as its dependent on the object it does not make sense that to be static.
Regards,
Ravi
Note : Please mark the helpful answers
Similar Messages
-
Hi all,
I am in confusion that which is called first static (method / attribute ) or Instance (method/attribute).
Becoz what i know is whenever an object is created, first static is called then instance.
please correct me if i am wrong.
regards,
satishHi Sathis,
Instance & Static Method :
if u declare one method as a static then we can call that method using class name, that method is independent of that object.You declare them using the CLASS-DATA statement.
if u declare one method as a instance then we can call that method using object name, that method is dependent of that object.You declare them using the DATA statement.
Instance & Static Attribute :
if u declare one attribute as a static then we can use that attribute through class name, that attribute is independent of that object.You declare static methods using the CLASS-METHODS statement.
if u declare one attribute as a instance then we can use that attribute through object name, that attribute is dependent of that object.You declare instance methods using the METHODS statement.
if u have any doubt ask me,
Regards,
Vijay
Edited by: Vijay.V on Dec 26, 2007 3:33 PM
Edited by: Vijay.V on Dec 26, 2007 3:36 PM -
Hi,
I am a self-taught Java programmer and have been writing Java code over the past 18 months. I am comfortable with general coding, but I am having great difficulty deciding whether a method should be static or instance.
In many cases, I decide to create a class which has maybe 1 or 2 methods. A good example of this is the class I wrote which allows me to pass it a JFrame and it then centres the JFrame on screen. Seems to me I can do 1 of 2 things.
1. Put the code in the class constructor and then call it with:
CentreMe cm = new CentreMe(this);
where CentreMe is the name of the class and this refers to the JFrame that is being passed
2. Put the code in a static method within the class and then call it with:
CentreMe.CenterFrame(this);
Assuming that all the CentreMe class does is to centre a frame in this way, which is the correct (or at least best) approach. Seems to me there is no point in creating objects as per option 1 when they are never used therafter?
If anyone has advice or a URL that deals with this particular "design" issue I would be very grateful.
Thanks
MarkGiven that design, then your intuition is correct, that method should be static. No need for objects there. But on a higher level, the design is backwards. Instead of having a separate class that knows how to centre a JFrame, it would be better to create a subclass of JFrame that knows how to centre itself. Have a look at Bruce Eckel's online book "Thinking in Java" ( http://www.bruceeckel.com ); it has a lot of useful information about the design of objects.
-
Purpose of declaring the method or class or static and as instance
what is the purpose of declaring a method in a class or the class itself as static.
Does it mean we cannot create a copy of that class or method if we declare it as static.
if so then why do they dont want that class to be created as a copy ?
Why do they want to declare a class as static
please provide some conceptual undersatnding regarding the static and instance class with one exampleStatic methods are often used for the implementation of utility methods. Please have a look at the class CL_ABAP_CHAR_UTILITIES for example.
You use the methods of this class in the same way as you would use a function in ABAP (like
LINES( itab )
). You use it in a static way because the functionality is always the same no matter in what context you are calling the function.
The purpose of instance methods is that their logic is in some way related to an attribute of the object instance that you use to call it.
For example, you create an instance of object PO (a purchase order) called MY_PO. Then the method
MY_PO->ADD_POSITION
would add a position to a concrete PO that has a unique number etc. But if the object has a static method DELETE_POSITION then it just deletes the current position of a PO, regardless on which concrete PO you are acting at the moment.
I hope this clarifies it for you.
Regards,
Mark -
Hello, I have this issue and Ihave wasted atleast 2 days with this one. I have tried all possible solutions -
1. Turn Off Real time McAffee scanning -- I do not have real time scanning ON
2. Delete Bin folder and start all over by adding references -- Did not work
3. delete .compiles or refresh filesdelete temp files from asp.net temp files folder -- no .Compiled file. Deleted refresh files but no use
4. change temp file for appliation in compilation tag of web config -- No use
My application framework is .NET 4.5 and VSD 2012. I have tried to compile from C:\WINDOWS\Mi
crosoft.NET\Framework folder as well as C:\WINDOWS\Mi
crosoft.NET\Framework64 folder. Both gave same error.
I need urgent assistance plz.
Here is stack trace :
C:\Development\Convergence\Applications\CAP\WixSetup\WixSetupView>"C:\WINDOWS\Mi
crosoft.NET\Framework\v4.0.30319\aspnet_compiler.exe" -u -fixedNames -p "C:\Deve
lopment\Convergence\Applications\CAP\TouchPointTier\Presentations" -v / "C:\Deve
lopment\Convergence\Applications\CAP\PrecompiledWeb\ConvergenceCAP" -errorstack
Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.17929
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
error ASPRUNTIME: Object reference not set to an instance of an object.
[NullReferenceException]: Object reference not set to an instance of an object.
at System.Web.Compilation.BuildManager.CopyPrecompiledFile(VirtualFile vfile,
String destPhysicalPath)
at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath star
tingVirtualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirt
ualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallba
ck callback, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCa
llback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCa
llback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuil
dManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuil
dManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
C:\Development\Convergence\Applications\CAP\WixSetup\WixSetupView>pause
Press any key to continue . . .I know these warning are not related to my issue that is the reason i am not able to understand what is wrong with it. Its a huge application and compiliing takes atleast 6-7 hrs and after that I get error in "copyPrecompiledFiles" method.
I have circular reference issue in application but when I build application in specific sequece, it goes away so after builing application with 0 errors, i execute command to precompile
rmdir C:\Precompiled /s /q
mkdir C:\Precompiled
"C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe" -u -fixedNames -p "C:\ApplicationPath" -v / "C:\Precompiled" -errorstack
pause -
Name space conflict between static and instance method
Hello,
there seems to be a very unfortunate name space conflict between static and instance method name. Consider:
static String description() that should return a description of a class.
String description() that should return a description of an instance.
That seems to confuse the compiler. How come? Static and instance methods don't have anything to get confused about.
Thanks for any insights :-)Umm...jeez.
It's not a bug, it's the way it's supposed to be.
Since a static method can be called the same way an instance method
A instance = new A();
A.staticMethod();
instance.staticMethod();it's not allowed.
Also in the class, you can call
public void myMethod() {
instanceMethodInClass(); // You don't need this, it's superfluous
staticMethodInClass(); // You don't need the class name.
}If you didn't understand, then just accept the fact that it is so. Some day you'll understand it. -
"object reference not set to an instance of an object" error while running ssrs report locally
Hi Folks,
I am a bit new to SSRS.
I am using ssrs 2012 and trying to use a method from a dll file. I am loaded the assembly file in reference of the report.
Now I am trying to use a static method from the Dll. e.g. applicationName.classname.MethodName()
But while running the report I am getting "object reference not set to an instance of an object" error.
For a note I am trying execute the report locally.
Any help would be highly appreciable.
sarat chandra sahooSorry for late reply Sinaloe..
I have added a dll file in my report reference. And in a textbox trying to execute this below.
=Recall.Common.LocalizationEx.Localization.GetString(Parameters!Culture.Value, "RFID", "BICustomerPortal")
where Getstring() is a static method in the dll.
I guess some configuration setting I am missing here.
1. I have copied these dlls in "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies" and "C:\Windows\Assembly".
sarat chandra sahoo -
Object reference not set to an instance of an object in treeView
Hello
I wrote this code. I have this Error "Object reference not set to an instance of an object" on " MessageBox.Show(tn.Text);"
in " MaintreeView_BeforeSelect ".
#region Remove BackColor of all treeview nodes
private void ClearBackColor()
TreeNodeCollection nodes = MaintreeView.Nodes;
foreach (TreeNode tn in nodes)
ClearRecursive(tn);
private void ClearRecursive(TreeNode treeNode)
foreach (TreeNode tn in treeNode.Nodes)
tn.BackColor = Color.Empty;
if(tn.IsSelected == true)
tn.TreeView.SelectedNode = null;
ClearRecursive(tn);
#endregion
private void MaintreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
ClearBackColor();
TreeNode tn = MaintreeView.SelectedNode;
if (tn != null)
MessageBox.Show(tn.Text);
if (tn.Level == 7)Hi ARZARE,
I tested your code, it can show the tn.Text when in the rootnode.
I suggest you putting the ClearBackColor() at the last of the BeforeSelect Event. Or this method will clear the selectNode.
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
//ClearBackColor();
TreeNode tn = this.treeView1.SelectedNode;
if (tn != null)
MessageBox.Show(tn.Text);
ClearBackColor();
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
"Object reference not set to an instance of an object" in WAD
10:45:09.659 ########## --> com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.SwitchEditable ##########
-EXCEPTION-START- 10:45:09.659: DEBUG ### Browser Init failed. 2nd try will be proceeded. ---
Exception Message: Object reference not set to an instance of an object.
Exception at SAPWADMXHTML.IWADMXBrowser2.AttachAnnotator(Boolean On)
at com.sap.bi.et.wad.AxSAPWADMXHTML.AxCWADMXBrowser2.AttachAnnotator(Boolean on)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.SwitchEditable(Boolean iBool)
Full Stack:
at com.sap.bi.et.wad.Debug.WriteTraceToFile(Level, String, Exception)
at com.sap.bi.et.wad.Debug.Exception(Exception, String)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.SwitchEditable(Boolean)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.set_BrowserDesignMode(Boolean)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.Navigate(String, Boolean)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.SetHTMLsafe(String, Boolean)
at com.sap.bi.et.wad.wadhtmlediting.WADctlWADHTMLControl.SetHTML(String, Boolean)
at com.sap.bi.et.wad.man.WADctlEditViewLayout.SetDocumentHTML(String)
at com.sap.bi.et.wad.man.WADctlEditViewLayout.TemplateXML2HTMLEdit()
at com.sap.bi.et.wad.man.WADfrmTemplateMDIWindow.UpdateView(Int32, Int32, Boolean)
at com.sap.bi.et.wad.man.WADfrmTemplateMDIWindow.tabLayoutTab_Switch(Object, EventArgs)
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs)
at System.Windows.Forms.TabControl.WmSelChange(Message&)
at System.Windows.Forms.TabControl.WndProc(Message&)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef, Int32, IntPtr, IntPtr)
at System.Windows.Forms.Control.SendMessage(Int32, IntPtr, IntPtr)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr, Message&)
at System.Windows.Forms.Control.WmNotify(Message&)
at System.Windows.Forms.Control.WndProc(Message&)
at System.Windows.Forms.ScrollableControl.WndProc(Message&)
at System.Windows.Forms.ContainerControl.WndProc(Message&)
at System.Windows.Forms.Form.WndProc(Message&)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.NativeWindow.DefWndProc(Message&)
at System.Windows.Forms.Control.DefWndProc(Message&)
at System.Windows.Forms.Control.WmMouseDown(Message&, MouseButtons, Int32)
at System.Windows.Forms.Control.WndProc(Message&)
at System.Windows.Forms.TabControl.WndProc(Message&)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32, ApplicationContext)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32, ApplicationContext)
at System.Windows.Forms.Application.Run(Form)
at com.sap.bi.et.wad.BexWebApplicationDesigner.Launch.Main()
-EXCEPTION-END----Hello Dieu,
Have you found a solution of this exception?? i also come across this one.
Kind Regards,
Clark -
Object Reference Not Set To An Instance Of An Object - Outlook Add-In - Add-In Express
Hi,
My Add-In has been developed in VS2010 using the Add-In Express pack.
Its a very simple add-in that shows an IT support ticket email detailing PC information. To use it, following installing the add-in, the user must select the tab in outlook and click on the Send IT Support Email button which will generate an Outlook Email
Template with specific information about the PC that I pull using VB.
It works fine in Windows 7 & 8, but throws an 'Object Reference Not Set To An Instance Of An Object' exception in Windows XP. Screenshot is shown below:
The code is below
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports AddinExpress.MSO
Imports System.Object
Imports System.Net
Imports System.Environment
Imports System.Net.NetworkInformation
Imports System.Windows.Forms.Application
Imports Microsoft.Office.Interop.Outlook
Imports outlook = Microsoft.Office.Interop.Outlook
'Add-in Express Add-in Module
<GuidAttribute("735B7BC8-DD2F-44D8-BC37-30D86769C065"), ProgIdAttribute("$safeprojectname$.AddinModule")> _
Public Class AddinModule
Inherits AddinExpress.MSO.ADXAddinModule
#Region " Add-in Express automatic code "
'Required by Add-in Express - do not modify
'the methods within this region
Public Overrides Function GetContainer() As System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function
<ComRegisterFunctionAttribute()> _
Public Shared Sub AddinRegister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXRegister(t)
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub AddinUnregister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXUnregister(t)
End Sub
Public Overrides Sub UninstallControls()
MyBase.UninstallControls()
End Sub
#End Region
Public Shared Shadows ReadOnly Property CurrentInstance() As AddinModule
Get
Return CType(AddinExpress.MSO.ADXAddinModule.CurrentInstance, AddinModule)
End Get
End Property
Private Sub AddInModule_AddInInitiatize(ByVal sender As Object, ByVal e As EventArgs) _
Handles MyBase.AddinInitialize
'Outlook 2010 = 14
If Me.HostMajorVersion >= 14 Then
AdxOlExplorerCommandBar1.UseForRibbon = False
End If
End Sub
Public ReadOnly Property OutlookApp() As Outlook._Application
Get
Return CType(HostApplication, Outlook._Application)
End Get
End Property
'Gets the MAC Address from the NIC Information
Function getMacAddress()
Dim nics() As NetworkInterface = _
NetworkInterface.GetAllNetworkInterfaces
Return nics(0).GetPhysicalAddress.ToString
End Function
Sub CreateTemplate()
Dim sHostName As String
Dim sDomain As String
Dim sUserName As String
Dim sOS As String
Dim s64 As String
Dim sMAC As String
Dim host As String = System.Net.Dns.GetHostName()
Dim LocalHostaddress As String = System.Net.Dns.GetHostEntry(host).AddressList(1).ToString()
Dim MyItem As Outlook.MailItem
'Finds the PC Number
sHostName = Environ$("computername")
'Finds the Domain
sDomain = Environ$("userdomain")
'Finds the Username logged into the PC
sUserName = (Environment.UserDomainName & "\" & Environment.UserName)
'Finds the Operating System
sOS = (My.Computer.Info.OSFullName)
'Shows the results collected from the getMacAddress Function in the sMac variable
sMAC = getMacAddress()
'Finds the Architecture of the Operating System - x86 or x64
If (Environment.Is64BitOperatingSystem) Then
s64 = ("64bit")
Else
s64 = ("32bit")
End If
'Creates a Template Email
MyItem = OutlookApp.CreateItem(Outlook.OlItemType.olMailItem)
'Configures the Sender as [email protected]
MyItem.To = "[email protected]"
'Shows the template
MyItem.Display()
'Shows all of the string in the Email Body
MyItem.HTMLBody = String.Concat("<b><u>IT SUPPORT TICKET</u></b>", "<br/><br/>", "<tr><b>PC Number: </b></tr>", sDomain, "\", sHostName, "<b></b>", "<br/><br/>", "<b>Username: </b>", sUserName, "<b></b>", "<br/><br/>", "<b>OS Version: </b>", sOS, s64, "<b></b>", "<br/><br/>", "<b>IP Address: </b>", LocalHostaddress, "<b></b>", "<br/><br/>", "<b>MAC Address: </b>", sMAC, "<b></b>", "<br/><br/>", "<b>Comment:</b>", "<br/>", "<i>Please give a brief description of your problem attaching a screen shot if possible</i>", "<br/><br/>") & MyItem.HTMLBody
End Sub
Private Sub AdxRibbonButton1_OnClick(ByVal sender As Object, ByVal control As IRibbonControl, ByVal pressed As Boolean) Handles AdxRibbonButton1.OnClick
'Runs CreateTemplate
CreateTemplate()
End Sub
Private Sub AdxCommandBarButton1_Click(ByVal sender As Object) Handles AdxCommandBarButton1.Click
'Runs CreateTemplate
CreateTemplate()
End Sub
End Class
I would appreciate any help with this whatsoever as I am pulling my hair out!!
Many Thanks!!
ChrisHi,
Welcome to MSDN forum.
I am afraid that the issue is out of support range of VS General Question forum which mainly discusses
the usage of Visual Studio IDE such as WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
and Visual Studio Editor.
Because your Add-in is developed using Add-in Express which is third-party, I suggest consulting Add-in Express forum:
http://www.add-in-express.com/forum/index.php for better support.
Best regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
"Object reference not set to an instance of an object" when using Sheel Shah's example
I am attempting to use a custom add dialog as in http://blogs.msdn.com/b/lightswitch/archive/2011/07/07/creating-a-custom-add-or-edit-dialog.aspx and
I get the error "Object reference not set to an instance of an object." when clicking my button to AddEntity(). My code to call the control is:
User u = new User();
userdialoghelper.AddEntity(u);
Any ideas as to why I'm getting this error? I "think" that I've set up the class properly?
ScottI may be a couple of years late to the party here (using VS2013) but I also had some issues adapting to Yann's improvements over Sheel's code.
Sheel's screen code as provided has the word "Old in the InitializeDataWorkspace and the created methods. this does not work when copy/pasted. ALso removed the "UI" from "InitialiseUI()"
Following code can be used with Yann's Helper Class.
Namespace LightSwitchApplication
Public Class EditableCustomersGrid
Private customersDialogHelper As ModalWindow
Private Sub EditableCustomersGrid_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
customersDialogHelper = New ModalWindow(Me.Customers, "CustomerViewDialog")
End Sub
Private Sub EditableCustomersGrid_Created()
customersDialogHelper.Initialise()
End Sub
Private Sub gridAddAndEditNew_CanExecute(ByRef result As Boolean)
customersDialogHelper.CanAdd()
End Sub
Private Sub gridAddAndEditNew_Execute()
customersDialogHelper.AddEntity()
End Sub
Private Sub gridEditSelected_CanExecute(ByRef result As Boolean)
customersDialogHelper.CanView()
End Sub
Private Sub gridEditSelected_Execute()
customersDialogHelper.ViewEntity()
End Sub
Private Sub EditDialogOk_Execute()
customersDialogHelper.DialogOk()
End Sub
Private Sub EditDialogCancel_Execute()
customersDialogHelper.DialogCancel()
End Sub
End Class
End Namespace -
Hello,
As you can tell from the title of this question, I am no expert with GPO's. Before I begin, I spent a few minutes to an hour searching and reading in hopes of finding the solution and avoid putting myself out there as a "GPO Newb". While
I found several posts and answers that were similar and were related, the questions and answers were more advanced and did present the solutions providing the person had initial knowledge already. That is not necessarily my case and I would ask for a
little patience and a bit of 'hand-holding' for what I need.
I run SBS 2011, and in Group Policy Management I have a custom GPO. In this GPO I define all my settings. I understand this may not be the best or most practical method of applying policies, but I am not very strict and have few settings. This
policy existed prior to my joining the company, and was migrated in to this SBS '11 from SBS '03. That may be the issue, but before making any changes I am seeking expert advice.
When I select that GPO, named "Main GPO", and click on the tab at the top "Settings" I see the error: "An error occurred while generating report: Object reference not set to an instance of an object."
I saw that when I right click the GPO > View > Options and select the tab "Reporting" that it states that for reporting to work the location of the .adm files must be specified. I see that my option for the location is set to "Default"
which by my guessing would be located in the C:\Windows\sysvol directory. Below is what I see there:
C:\Windows\sysvol\domain
C:\Windows\sysvol\staging
C:\Windows\sysvol\staging areas
C:\Windows\sysvol\sysvol
I think the problem is that my custom GPO are not inside the default location, which I speculate is: C:\Windows\sysvol\domain\policies (which I do see some objects there).
But instead I also see items in this folder: C:\Windows\sysvol\sysvol\JOHN.LOCAL\policies (while where I just typed 'JOHN.LOCAL' is my actual local domain).
To further this, when I edit that custom GPO, then at the very top of the tree I right click on it and select Properties, I see a Unique Name listed there as a long string of numbers and letters, similar to a registry entry. I searched my server for
that same Unique Name and found it listed inside the folder: C:\Windows\sysvol\domain\policies
If I am correct with my assumption and basic knowledge, I should move all objects as follows:
-Move FROM: C:\Windows\sysvol\domain\policies
-Move TO: C:\Windows\sysvol\sysvol\JOHN.LOCAL\policies
My concerns are that I am not correct at all, that I will break something, that there may be an easier fix than moving anything, or that I am overlooking something causing this error altogether.
Thank you for anyone's help and time with assisting me with this request.
John Fester> top "Settings" I see the error: "An error occurred while generating
> report: Object reference not set to an instance of an object."
That's due to a security setting (most possibly) your current OS does
not understand. Hard to find out wich exact setting it is... To resolve
this issue, we need the gtpptmpl.inf file residing in the policiy's
sysvol folder. To open this folder, edit the policy, move to computer
settings - policies - windows settings - scripts - startup, press "show
files". Then move two folders upwards and back down to
.\microsoft\windows nt\secedit. There you'll see the gpttmpl.inf - post
its contents and we'll have a look at it.
> location, which I speculate is: C:\Windows\sysvol\domain\policies (which
> folder: C:\Windows\sysvol\sysvol\JOHN.LOCAL\policies (while where I just
That's perfectly ok - JOHN.LOCAL in fact is a symlink pointing to "domain".
> all objects as follows:
> -Move FROM: C:\Windows\sysvol\domain\policies
> -Move TO: C:\Windows\sysvol\sysvol\JOHN.LOCAL\policies
No.
Martin
Mal ein
GUTES Buch über GPOs lesen?
NO THEY ARE NOT EVIL, if you know what you are doing:
Good or bad GPOs?
And if IT bothers me - coke bottle design refreshment :)) -
"Object reference not set to an instance of an object" on stored proc.
So, I use VS 2005 with Oracle 11 rel. 11.1.06.0.
I installed ODP for .net (ODAC 11.10621).
but, when I call some stored proc wich was working previously, when calling stored proc:
oProcAppendWebFolder2.Parameters("p_siteid").Value = vSiteID
oProcAppendWebFolder2.Parameters("p_webfoldername").Value = vWebFolderName
oProcAppendWebFolder2.Parameters("p_includestartpage").Value = IIf(vIncludeStartPage, "Y", "N")
oProcAppendWebFolder2.ExecuteNonQuery()
I often got message:
Object reference not set to an instance of an object. (I got this message when calling ExecuteNonQuery)
proc is simple:
FUNCTION AppendWebFolder(p_SiteID IN NUMBER, p_WebFolderName IN VARCHAR2, p_includeStartPage IN char) RETURN NUMBER AS
v_errcode PLS_INTEGER :=0;
v_retval PLS_INTEGER :=0;
BEGIN
UPDATE DBSEQUENCES SET VALUE=NVL(VALUE,0)+1
WHERE seqid=4
RETURNING VALUE INTO v_retval;
INSERT INTO WEBFOLDERS(webfolderid, siteid, webfoldername, include_startpage)
VALUES (v_retval, p_siteid, p_webfoldername, p_includestartpage);
RETURN (v_retval);
EXCEPTION
WHEN OTHERS THEN
v_errcode := SQLCODE;
g_errm := SUBSTR(SQLERRM,1,LONG_VARCHAR);
Appenderror(g_errm, 0, class_name, 'AppendWebFolder', 'siteid: ' || p_siteid || ' webfoldername: ' || p_webfoldername,0);
RETURN (v_errcode);
END AppendWebFolder;
procedure call declaratiion in .net is:
oProcAppendWebFolder2 = New OracleCommand("appendwebfolder", oConn)
oProcAppendWebFolder2.CommandType = CommandType.StoredProcedure
oProcAppendWebFolder2.Parameters.Add("retval", OracleDbType.Int32, ParameterDirection.ReturnValue)
oProcAppendWebFolder2.Parameters.Add("p_siteid", OracleDbType.Int32, ParameterDirection.Input)
oProcAppendWebFolder2.Parameters.Add("p_webfoldername", OracleDbType.Varchar2, ParameterDirection.Input)
oProcAppendWebFolder2.Parameters.Add("p_includestartpage", OracleDbType.Char, 1, "", ParameterDirection.Input)
oProcAppendWebFolder2.Prepare()
note that such error was not appearing when I used oracle XE
Edited by: user465054 on Dec 17, 2008 9:47 AMIf it is a web application, I would suggest using HTTP sessions to store the ReportDocument object.
See this KB for reference code on how to use session.
http://search.sap.com/ui/notes?id=0001985571&boj=/sap/bc/bsp/spn/scn_bosap/notes.do?access=69765F6D6F64653D3939382669765F7361706E6F7465735F6E756D6265723D30303031393835353731&ssocompatible
If that does not resolve the issue, provide below info.
- Version of CR with patch level.
- Version of VS
- Win or web app?
- What happens when you refresh the report in viewer using refresh button?
Thanks,
Bhushan -
Crawler Help: Object reference not set to an instance of an object
I'm trying to write a custom crawler and having some difficulties. I'm getting the document information from a database. I'm trying to have the ClickThroughURL be a web URL and the IndexingURL be a UNC path to the file on a back-end file share. Also, I'm not using DocFetch. The problem I'm having is that when the crawler runs I get the following error for every card:
"4/19/05 13:43:30- (940) Aborted Card creation for document: TestDoc1. Import error: IDispatch error #19876 (0x80044fa4): [Error Importing Card.
Error writing Indexing File.
SOAP fault: faultcode='soap:Server' faultstring='Server was unable to process request. --> Object reference not set to an instance of an object.']"
Has anyone seen this before? Any help you can provide would be greatly appreciated. I have included the code from my document.vb in case that helps.
Thanks,
Jerry
DOCUMENT.VB
Imports System
Imports Plumtree.Remote.Util
Imports Plumtree.Remote.Crawler
Imports System.Resources
Imports System.Globalization
Imports System.Threading
Imports System.IO
Imports System.Data.SqlClient
Imports System.Text
Namespace Plumtree.Remote.CWS.MoFoDocsOpen
Public Class Document
Implements IDocument
Private m_logger As ICrawlerLog
Private DocumentLocation As String
Private d_DocumentNumber As Integer
Private d_Library As String
Private d_Name As String
Private d_Author As String
Private d_AuthorID As String
Private d_Category As String
Private d_ClientName As String
Private d_ClientNumber As String
Private d_DateCreated As DateTime
Private d_DocumentName As String
Private d_DocumentType As String
Private d_EnteredBy As String
Private d_EnteredByID As String
Private d_FolderID As String
Private d_KEFlag As String
Private d_LastEdit As DateTime
Private d_LastEditBy As String
Private d_LastEditByID As String
Private d_Maintainer As String
Private d_MaintainerID As String
Private d_MatterName As String
Private d_MatterNumber As String
Private d_Practice As String
Private d_Description As String
Private d_Version As Integer
Private d_Path As String
Private d_FileName As String
Public Sub New(ByVal provider As DocumentProvider, ByVal documentLocation As String, ByVal signature As String)
Dim location() As String = DocumentLocation.Split("||")
Me.DocumentLocation = DocumentLocation
Me.d_DocumentNumber = location(0)
Me.d_Library = location(2)
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim objRec As SqlDataReader
objConn.ConnectionString = "Server=sad2525;Database=PortalDocs;Uid=sa;Pwd=;"
objConn.Open()
objCmd.CommandText = "SELECT * FROM DocsOpenAggregate WHERE Library = '" & Me.d_Library & "' AND DocumentNumber = " & Me.d_DocumentNumber
objCmd.Connection = objConn
objRec = objCmd.ExecuteReader()
Do While objRec.Read() = True
Me.d_Name = objRec("Name")
Me.d_Author = objRec("Author")
Me.d_AuthorID = objRec("AuthorID")
Me.d_Category = objRec("Category")
Me.d_ClientName = objRec("ClientName")
Me.d_ClientNumber = objRec("ClientNumber")
Me.d_DateCreated = objRec("DateCreated")
Me.d_DocumentName = objRec("DocumentName")
Me.d_DocumentType = objRec("DocumentType")
Me.d_EnteredBy = objRec("EnteredBy")
Me.d_EnteredByID = objRec("EnteredByID")
Me.d_FolderID = objRec("FolderID")
Me.d_KEFlag = objRec("KEFlag")
Me.d_LastEdit = objRec("LastEdit")
Me.d_LastEditBy = objRec("LastEditBy")
Me.d_LastEditByID = objRec("LastEditByID")
Me.d_Maintainer = objRec("Maintainer")
Me.d_MaintainerID = objRec("MaintainerID")
Me.d_MatterName = objRec("MatterName")
Me.d_MatterNumber = objRec("MatterNumber")
Me.d_Practice = objRec("Practice")
Me.d_Description = objRec("Description")
Me.d_Version = objRec("Version")
Me.d_Path = objRec("Path")
Me.d_FileName = objRec("FileName")
Loop
objCmd = Nothing
If objRec.IsClosed = False Then objRec.Close()
objRec = Nothing
If objConn.State <> ConnectionState.Closed Then objConn.Close()
objConn = Nothing
End Sub
'If using DocFetch, this method returns a file path to the document in the backend repository.
Public Function GetDocument() As String Implements IDocument.GetDocument
m_logger.Log("Document.GetDocument called for " & Me.DocumentLocation)
Return Me.d_Path
End Function
'Returns the metadata information about this document.
Public Function GetMetaData(ByVal aFilter() As String) As DocumentMetaData Implements IDocument.GetMetaData
m_logger.Log("Document.GetMetaData called for " & DocumentLocation)
Dim DOnvp(23) As NamedValue
DOnvp(0) = New NamedValue("Author", Me.d_Author)
DOnvp(1) = New NamedValue("AuthorID", Me.d_AuthorID)
DOnvp(2) = New NamedValue("Category", Me.d_Category)
DOnvp(3) = New NamedValue("ClientName", Me.d_ClientName)
DOnvp(4) = New NamedValue("ClientNumber", Me.d_ClientNumber)
DOnvp(5) = New NamedValue("DateCreated", Me.d_DateCreated)
DOnvp(6) = New NamedValue("DocumentName", Me.d_DocumentName)
DOnvp(7) = New NamedValue("DocumentType", Me.d_DocumentType)
DOnvp(8) = New NamedValue("EnteredBy", Me.d_EnteredBy)
DOnvp(9) = New NamedValue("EnteredByID", Me.d_EnteredByID)
DOnvp(10) = New NamedValue("FolderID", Me.d_FolderID)
DOnvp(11) = New NamedValue("KEFlag", Me.d_KEFlag)
DOnvp(12) = New NamedValue("LastEdit", Me.d_LastEdit)
DOnvp(13) = New NamedValue("LastEditBy", Me.d_LastEditBy)
DOnvp(14) = New NamedValue("LastEditByID", Me.d_LastEditByID)
DOnvp(15) = New NamedValue("Maintainer", Me.d_Maintainer)
DOnvp(16) = New NamedValue("MaintainerID", Me.d_MaintainerID)
DOnvp(17) = New NamedValue("MatterName", Me.d_MatterName)
DOnvp(18) = New NamedValue("MatterNumber", Me.d_MatterNumber)
DOnvp(19) = New NamedValue("Practice", Me.d_Practice)
DOnvp(20) = New NamedValue("Description", Me.d_Description)
DOnvp(21) = New NamedValue("Version", Me.d_Version)
DOnvp(22) = New NamedValue("Path", Me.d_Path)
DOnvp(23) = New NamedValue("FileName", Me.d_FileName)
Dim metaData As New DocumentMetaData(DOnvp)
Dim strExt As String = Right(Me.d_FileName, Len(Me.d_FileName) - InStrRev(Me.d_FileName, "."))
Select Case LCase(strExt)
Case "xml"
metaData.ContentType = "text/xml"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "vsd"
metaData.ContentType = "application/vnd.visio"
metaData.ImageUUID = "{2CEEC472-7CF0-11d3-BB3A-00105ACE365C}"
Case "mpp"
metaData.ContentType = "application/vnd.ms-project"
metaData.ImageUUID = "{8D6D9F50-D512-11d3-8DB0-00C04FF44474}"
Case "pdf"
metaData.ContentType = "application/pdf"
metaData.ImageUUID = "{64FED895-D031-11D2-8909-006008168DE5}"
Case "doc"
metaData.ContentType = "application/msword"
metaData.ImageUUID = "{0C35DD71-6453-11D2-88C3-006008168DE5}"
Case "dot"
metaData.ContentType = "application/msword"
metaData.ImageUUID = "{0C35DD71-6453-11D2-88C3-006008168DE5}"
Case "rtf"
metaData.ContentType = "text/richtext"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "xls"
metaData.ContentType = "application/vnd.ms-excel"
metaData.ImageUUID = "{0C35DD72-6453-11D2-88C3-006008168DE5}"
Case "xlt"
metaData.ContentType = "application/vnd.ms-excel"
metaData.ImageUUID = "{0C35DD72-6453-11D2-88C3-006008168DE5}"
Case "pps"
metaData.ContentType = "application/vnd.ms-powerpoint"
metaData.ImageUUID = "{0C35DD73-6453-11D2-88C3-006008168DE5}"
Case "ppt"
metaData.ContentType = "application/vnd.ms-powerpoint"
metaData.ImageUUID = "{0C35DD73-6453-11D2-88C3-006008168DE5}"
Case "htm"
metaData.ContentType = "text/html"
metaData.ImageUUID = "{D2E2D5E0-84C9-11D2-A0C5-0060979C42D8}"
Case "html"
metaData.ContentType = "text/html"
metaData.ImageUUID = "{D2E2D5E0-84C9-11D2-A0C5-0060979C42D8}"
Case "asp"
metaData.ContentType = "text/plain"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "idq"
metaData.ContentType = "text/plain"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "txt"
metaData.ContentType = "text/plain"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "log"
metaData.ContentType = "text/plain"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case "sql"
metaData.ContentType = "text/plain"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
Case Else
metaData.ContentType = "application/octet-stream"
metaData.ImageUUID = "{F8F6B82F-53C6-11D2-88B7-006008168DE5}"
End Select
metaData.Name = Me.d_Name
metaData.Description = Me.d_Description
metaData.FileName = Me.d_FileName ' This is a file name - for example "2jd005_.DOC"
metaData.IndexingURL = Me.d_Path ' This is a file path - for example "\\fileserver01\docsd$\SF01\DOCS\MLS1\NONE\2jd005_.DOC"
metaData.ClickThroughURL = "http://mofoweb/docsopen.asp?Unique=" & HttpUtility.HtmlEncode(Me.DocumentLocation)
metaData.UseDocFetch = False
Return metaData
End Function
'Returns the signature or last-modified-date of this document that indicates to the portal whether the document needs refreshing.
Public Function GetDocumentSignature() As String Implements IDocument.GetDocumentSignature
Dim SigString As New StringBuilder
Dim SigEncode As String
SigString.Append(Me.d_DocumentNumber & "||")
SigString.Append(Me.d_Library & "||")
SigString.Append(Me.d_Name & "||")
SigString.Append(Me.d_Author & "||")
SigString.Append(Me.d_AuthorID & "||")
SigString.Append(Me.d_Category & "||")
SigString.Append(Me.d_ClientName & "||")
SigString.Append(Me.d_ClientNumber & "||")
SigString.Append(Me.d_DateCreated & "||")
SigString.Append(Me.d_DocumentName & "||")
SigString.Append(Me.d_DocumentType & "||")
SigString.Append(Me.d_EnteredBy & "||")
SigString.Append(Me.d_EnteredByID & "||")
SigString.Append(Me.d_FolderID & "||")
SigString.Append(Me.d_KEFlag & "||")
SigString.Append(Me.d_LastEdit & "||")
SigString.Append(Me.d_LastEditBy & "||")
SigString.Append(Me.d_LastEditByID & "||")
SigString.Append(Me.d_Maintainer & "||")
SigString.Append(Me.d_MaintainerID & "||")
SigString.Append(Me.d_MatterName & "||")
SigString.Append(Me.d_MatterNumber & "||")
SigString.Append(Me.d_Practice & "||")
SigString.Append(Me.d_Description & "||")
SigString.Append(Me.d_Version & "||")
SigString.Append(Me.d_Path & "||")
SigString.Append(Me.d_FileName & "||")
Dim encoding As New UTF8Encoding
Dim byteArray As Byte() = encoding.GetBytes(SigString.ToString())
SigEncode = System.Convert.ToBase64String(byteArray, 0, byteArray.Length)
Return SigEncode
End Function
'Returns an array of the users with access to this document.
Public Function GetUsers() As ACLEntry() Implements IDocument.GetUsers
'no acl info retrieved
Dim aclArray(-1) As ACLEntry
Return aclArray
End Function
'Returns an array of the groups with access to this document.
Public Function GetGroups() As ACLEntry() Implements IDocument.GetGroups
'no acl info retrieved
Dim aclArray(-1) As ACLEntry
Return aclArray
End Function
End Class
End Namespace1. I don't think you can just set the index url to a unc path.
2. Try creating an index aspx page. In your MetaData.IndexURL set it to the index aspx page, and include query string params for the encoded unc path as well as the content type.
3. In the index servlet, get the content type and path from the query string
4. Get the filename from the file path
5. Set the headers for content-type and Content-Disposition, e.g.
Response.ContentType="application/msword"
Response.AddHeader("Content-Disposition", "inline; filename'" + filename)
6. Stream out the file:
FileStream fs = new FileStream(path, FileMode.Open)
byte[] buffer = new byte[40000]
int result
System.IO.Stream output = Response.OutputStream
do
result = fs.Read(buffer, 0, 40000)
output.Write(buffer, 0, result)
while (result == 40000)
put the above in a try-catch, and then delete the temp file in the finally block.
If this does not help, set a breakpoint in the code to find the error. Also use Log4Net to log any errors. -
hi,
We have deployed Sharepoint 2013 in hosting mode. And i followed this
guide. And i have 1 web server, 1 app server and 1 DB server. My Application server is logging 2 critical event after every 15 min.
Event ID: 1502, Task Category: Timer Job, Source: SharePoint Translation Services
"Timer job '735da5fd-a74a-46b8-9a75-70e85d125eb2' for service application 'Translation Service Application' is failing to execute. More information is included below.
Object reference not set to an instance of an object. "
Followed by this one one more critical event,
Event ID: 6398, Task Category: Timer , Source: SharePoint Foundation
"The Execute method of job definition Microsoft.Office.TranslationServices.QueueJob (ID 735da5fd-a74a-46b8-9a75-70e85d125eb2) threw an exception. More information is included below.
Object reference not set to an instance of an object."
I tried to search everywhere, but no solution. Because of this two critical events AppFabricCaching service is also crashing.
Any suggestion how i can fix this?
SaMHi SaM,
According to your error message, it says that the Timer job '735da5fd-a74a-46b8-9a75-70e85d125eb2' for service application 'Translation Service Application' fail to create due to some referred object cannot
be found. For this issue, it can be caused by missing assembly .
Could you please provide detail error message of ULS log to determine the exact cause of the error?
For SharePoint 2013, by default, ULS log is at
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
Here is a blog you can have a look:
http://powerpivotgeek.com/2010/10/04/bug-cannot-install-powerpivot-if-a-sql-server-shared-folder-has-been-specified-in-a-previous-installation-to-other-than-the-default-folder/
Best Regards,
Eric
Eric Tao
TechNet Community Support
Maybe you are looking for
-
How to selectively allow traffic to only particular websites to particular computers
For a particular server, we would like to allow access to a particular website and block the all other internet traffic. I have created an identity with that particular server, an access policy linked to a particular identity and custom URL category
-
I am having issues with the address book in iphone 4s ios 7. it won't let me add and adress for a new contact. anybody has an idea of what's wrong and the solution ?
-
Password protecting certain folders on a mac.
I have 2 macs in the house and 3 pcs connected through a netgear wireless router. One of my macs is shared and has all documents and folders that all the other computers can see. I want to password protect some folders so that other computers need
-
Flex 4.5 mxml based application not running after iOS packaging on i pad
I have created one mxml based application on flex 4.5 and make the .ipa file by iOS packaging of adt command.The command goes as followes adt -package -target ipa-debug -storetype pkcs12 -keystore development_key.p12 -provisioning-profile flex_air.
-
I have 36 images in a movie clip. Inside of that movie clip there are 36 other movie clips containing one separate image. I have figured out how to click on them and add it to the stage. BUT i can figure out how to get them to remove when another ima