A DotNet variable has not been instantiated. System.Net.WebResponse.GetResponseStream

CGaralde
Member Posts: 19
Hi,
I have some code which I use to log API errors in NAV and it was working until yesterday. I have Googled this "instantiated" error and I read that I should call the constructor first but for the life of me I cannot understand what it means.
So from what I understand, the GetResponseStream here is the method, which one is the constructor that I need to call first then?
I am asking this question in my head and it seems silly but I would appreciate any input.
I have some code which I use to log API errors in NAV and it was working until yesterday. I have Googled this "instantiated" error and I read that I should call the constructor first but for the life of me I cannot understand what it means.
So from what I understand, the GetResponseStream here is the method, which one is the constructor that I need to call first then?
Exception := GETLASTERROROBJECT; WebException := Exception.InnerException; Response := WebException.Response; Response.GetResponseStream; //error here StreamReader := StreamReader.StreamReader(Response.GetResponseStream); ReqString := StreamReader.ReadToEnd;
Name DataType Subtype Length Exception DotNet System.Exception.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' WebException DotNet System.Net.WebException.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Response DotNet System.Net.WebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' StreamReader DotNet System.IO.StreamReader.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ReqString DotNet System.String.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I am asking this question in my head and it seems silly but I would appreciate any input.
0
Answers
-
Hi CG,
Refer below .net example to understand:
https://docs.microsoft.com/en-us/dotnet/api/system.net.webresponse.getresponsestream?view=net-5.0
something like the below declaration in C#:
// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myWebResponse.GetResponseStream();0 -
Hi tabrezajaz,
First of all, thanks for taking the time to look into my post.
I actually tried this just after I posted the question to see if it made any difference, unfortunately I am still getting the same error:Exception := GETLASTERROROBJECT; WebException := Exception.InnerException; Response := WebException.Response; Stream := Response.GetResponseStream; StreamReader := StreamReader.StreamReader(Stream); ReqString := StreamReader.ReadToEnd;
Name DataType Subtype Length Exception DotNet System.Exception.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' WebException DotNet System.Net.WebException.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Response DotNet System.Net.WebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Stream DotNet System.IO.Stream.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' StreamReader DotNet System.IO.StreamReader.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ReqString DotNet System.String.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
0 -
if you are running .net from nav, you have to call constructor like:
metapackConstructor:=metapackConstructor.MetaPackProgram();
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions