Object reference not set to an instance of an object.

starstarstarstarstarstarstarstarstarstar Rating: 0/5 (0 vote cast) print
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 36: string parse_txt = ""; Line 37: Line 38: parse_txt = wGramC.Parse(myWords); Line 39: Line 40: }

Source File: c:inetpubwwwrootwebparserwgramc.cs    Line: 38
Stack Trace:
[NullReferenceException: Object reference not set to an instance 
of an object.] webParser.wGramC.Parse(String input) +0
webParser.wGramC.parsingTxt(String myWords) in
c:inetpubwwwrootwebparserwgramc.cs:38 webParser.
WebForm1.menuItem8_Click(Object sender, EventArgs e) in
c:inetpubwwwrootwebparserwebform1.aspx.cs:256
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler
.RaisePostBackEvent(String eventArgument) System.Web.UI.Page
.RaisePostBackEvent(IPostBackEventHandler sourceControl,
String eventArgument) System.Web.UI.Page.RaisePostBackEvent
(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()
 : geezmoh     Reply  

Replies (11)

profile
KINGSLEY TAGBO

Your DllImport may not be creating an object to start with.
After your DllImport and before you call wGramC.Parse, check if the object is valid :
E.g.
[code language="c#"]
if (wGramC != null)
{
  wGramC.Parse ...
}
else
{
  System.Diagnostics.Debug.WriteLine("null wGramC Object ...");
}[/code]


thnx kingsley...
But hang in there plss..
This is the problem... I have a running window application with the dll import code and it's running smoothly... then I decided to convert it to web application...
 
I got this four dll import code...

[DllImport("link41a.dll", EntryPoint="Init", CallingConvention=CallingConvention.StdCall)]

public static extern int Init(string dict, string knowledge, string constituent_knowledge, string affix);

[DllImport("link41a.dll", EntryPoint="Parse", CallingConvention=CallingConvention.StdCall)]

public static extern string Parse(string input);

[DllImport("link41a.dll", EntryPoint="ParseDiagram", CallingConvention=CallingConvention.StdCall)]

public static extern string ParseDiagram(string input);

[DllImport("link41a.dll", EntryPoint="Release", CallingConvention=CallingConvention.Winapi)]

public static extern void Release();
then i have this weird problem...
 

Server Error in '/webParser' Application.

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 about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:

Line 252: public void menuItem8_Click(object sender, 
System.EventArgs
e) Line 253: { Line 254: wGramC.Release(); Line 255:
if (wGramC.Init("4.0.dict","4.0.knowledge",
"4.0.constituent-knowledge","4.0.affix") != 1)
Line 256:
System.Diagnostics.Debug.WriteLine("null wGramC Object ...");

Source File: c:inetpubhttp://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6821    Line: 254
Stack Trace:
[NullReferenceException: Object reference not set to an instance of 
an object.] webParser.wGramC.Release() +0
webParser.WebForm1.menuItem8_Click(Object sender, EventArgs e)
in c:inetpubhttp://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6821:254
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.
RaisePostBackEvent(String eventArgument) System.Web.UI.Page.
RaisePostBackEvent(IPostBackEventHandler sourceControl,
String eventArgument) System.Web.UI.Page.RaisePostBackEvent
(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

PLEASE HELP ME...

: geezmoh    Reply

profile
KINGSLEY TAGBO

GEEZMOH :
Put the Link41a.dll in your System Folder (System32)
Change the calls to Link41a.dll to refer to the full path of the dll e.g. C:WINNTSYSTEM32LINK41A.DLL
Finally please give me a feedback  [H] if it works.
Thanks


I just did what u told me too...But i got the same problem...by the way the wGramC.Init is working why the other like the Parse didn't work...What do u mean by "Change the calls to Link41a.dll to refer to the full path of the dll e.g. C:WINNTSYSTEM32LINK41A.DLL"I will re code the dll??Please be patient with me... Thnx a lot.. please help me...

: geezmoh    Reply

profile
KINGSLEY TAGBO

Geezmoh :
Leave the dll file in the local bin directory (not system32).
Change the DllImport line to look like :

[DllImport("c:inetpubhttp://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6975" .....


Kingsley Tagbo

[DllImport("C:/Inetpub/http://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6976", EntryPoint="Release", CallingConvention=CallingConvention.StdCall)]

public static extern void Release();
I got the same problem I think the import is working because I don't have any problem in
 
[DllImport("c:/windows/system32/link41a.dll", EntryPoint="Init", CallingConvention=CallingConvention.StdCall)]

public static extern int Init(string dict, string knowledge, string constituent_knowledge, string affix);

hmm any Idea in mind.. Sorry for the time you spent but please don't leave me...
Thnx A lot.... I hope you have any solutions our there.

: geezmoh    Reply

profile
KINGSLEY TAGBO

Can you try replacing all calls to DllImport("CLink41a.dll" to DllImport("c:/windows/system32/link41a.dll" or whatever the ful path to your dll is.See these references : http://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6977http://www.kdkeys.net/object-reference-not-set-to-an-instance-of-an-object/#link-6978


Kingsley Tagbo
WWHHOOOAAAAAAA

Just fix the problem Thnx man ur great... and thnx to you reference it helps me a lot...

The fix procedure...
In web Application just put the dll in your system32 folder..
I just post the solution for the other that having the same problem...

: geezmoh    Reply

profile
KINGSLEY TAGBO

Please do one thing for me.Please post the description of your solution and then vote on the thread according to how you feel about this post.Thanks a lot.


profile
KINGSLEY TAGBO

It looks like your object wGramC.Parse is not instantiated.


please help me... how can I intiate my wGramC.parse.... I has static value in it...

this is the code that i do for my dll import...
[DllImport("link41a.dll", EntryPoint="Parse", CallingConvention=CallingConvention.StdCall)]

public static extern string Parse(string input);


I got the same problem... Please help..
: geezmoh    Reply


Post A Reply

 Questions & Answers