I'm trying to build an app for android (school project (technology)), however,
I'm keep getting an error and searching on the internet, gave no answer. So I'm hereby asking in here.
I got an MySQL 5.6 Server up and running, it works. PHP standalone and Xampp for file directory, and everything works fine in browser. The error occurs on the the arrow sign and exception error is about access (I think). I can upload the PHP files if needed.
The first one is a button, the second is an event fired when download is complete.
private void LoginButton_Click(object sender, EventArgs e)
{
TextView userName = FindViewById<TextView>(Resource.Id.editTextUsername);
TextView userPass = FindViewById<TextView>(Resource.Id.editTextPassword);
client = new WebClient();
url = new Uri(#"http://127.0.0.1/memento/accountcheck.php");
//url = new Uri(#"http://127.0.0.1/memento/phpinfo.php");
/*
NameValueCollection parameters = new NameValueCollection();
parameters.Add("Username", userName.Text);
parameters.Add("Password", userPass.Text);
*/
client.DownloadDataCompleted += Client_DownloadDataCompleted;
client.DownloadDataAsync(url);
}
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Console.WriteLine(e.Result); // <------
}
EDIT:
Unhandled Exception: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
Exception Settings: C++ Exceptions, Common Language Runtime Exceptions, JavaScript Runtime Exceptions, Managed Debugging Assistants & Win32 Exceptions.
Each contain tons of check checkboxes except JavaScript. It contains one "0x80070005 Access is denied".
Related
I am developing an Optical character recognition software using WPF.
I have third party hardware that does this ocr thing. I also have the device driver provided from the manufacture.
I have referenced the device driver's dll in my project and I call one of its method to convert image to text. For example, I can put my passport on the device and I get array of information from the passport.
The function works as expected but sometimes the application closes without any exception thrown. This is due to the device driver dll as seen from the window event logs. There is an unhandled exception in the dll that closes the application suddenly.
I want my WPF application to run no matter the whatever be the exception thrown by the dll file.
I have globally handled error in the app.cs file
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
var dialogContent = "Exception Message:" + "\n" + e.Exception.Message +
"\n" + "Stack Trace:" + "\n" + e.Exception.StackTrace;
MessageBox.Show(dialogContent);
e.Handled = true;
}
I have also added tried to add these attributes on my method.
[SecurityCritical]
[HandleProcessCorruptedStateExceptions]
public void ConvertImagetoText()
{
try
{
//do something from the dll file.
}
catch
{
throw;
}
}
In my UWP app I have the following code:
private async void testButton_Click(object sender, RoutedEventArgs e)
{
var picker = new Windows.Storage.Pickers.FolderPicker();
StorageFolder folder = await picker.PickSingleFolderAsync();
}
but when I run this it fails on the second line with the message An exception of type 'System.Runtime.InteropServices.COMException' occurred in .... but was not handled in user code. The HRESULT from the exception is -2147467259 = 0x80004005 = E_FAIL.
I'm using file pickers already elsewhere in the app without problem. This is running on a Win10 desktop (launched from VS2015). Can anyone suggest why the error occurs and/or what to do to resolve it? Having a meaningless error message in what appears to be the simplest code possible I'm not sure how to proceed.
This is a bit of an oddity in WinRT. Although it is not mentioned in the documentation explicitly, it is necessary to add at least one item in the FileTypeFilter collection:
var folderPicker = new FolderPicker();
folderPicker.FileTypeFilter.Add("*");
await folderPicker.PickSingleFolderAsync();
You can use a specific extension like ".jpg", but it doesn't seem to have effect in a FolderPicker anyway. The only thing that matters is that at least one valid item is present.
I'm trying to throw together a simple app that uses pedometer data on a Windows 10 phone. I normally live down in kernel-land, and this is my first time using most of the c# async stuff, so I'm wondering if I'm missing a core concept here.
My first attempt at getting data out was to simply report the number of recorded steps over the last hour to a textbox in my XAML app. I just created a basic XAML app, dropped a text box in, and added this event handler:
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
var history = await Pedometer.GetSystemHistoryAsync(DateTimeOffset.Now.AddHours(-1), TimeSpan.FromHours(1));
int count = history.Sum(entry => entry.CumulativeSteps);
textSteps.Text = count.ToString();
}
A breakpoint on the first line triggers, but before it hits the next line I get an unhandled exception. Error code -2147467259, message "Error HRESULT E_FAIL has been returned from a call to a COM component."
The top frame of the stack is in my code, but it's just the boilerplate line from App.g.i.cs that triggers a break on an unhandled exception. Below that is mscorlib and the WinRT invoker.
I looked through the app capabilities list in the manifest, and didn't find anything that looked like it applied to the pedometer. I'm testing this on a Lumia 950.
UPDATE: I just tried calling the API to get the default pedometer sensor:
Pedometer p = await Pedometer.GetDefaultAsync();
It turns out that this triggers an access denied exception with the same worthless stack. I'm currently doing more research to see if there is something that needs to be specified in the manifest.
After further experimenting got me an access denied error, I looked into the manifest more. The manifest Microsoft example project for the pedometer declares a device property that I can't find a way to add through the designer view. Adding it to the code worked perfectly. It's saying I've taken 300,000 steps in the last hour, but I'm sure some simple debugging will find the answer there. (The property is called CumulativeSteps, so that's a good hint...)
<Capabilities>
<DeviceCapability Name="activity" />
</Capabilities>
var currentReadings = await Pedometer.GetSystemHistoryAsync(DateTime.Today);
var walklist = new List<PedometerReading>();
var runlist = new List<PedometerReading>();
foreach (var cuurentreading in currentReadings)
{
if (cuurentreading.StepKind == PedometerStepKind.Walking)
{
walklist.Add(cuurentreading);
}
if (cuurentreading.StepKind == PedometerStepKind.Running)
{
runlist.Add(cuurentreading);
}
}
var item = walklist.Last();
var item1 = walklist.First();
var item2 = runlist.Last();
var item3 = runlist.First();
Steps1.Value += (item.CumulativeSteps - item1.CumulativeSteps);
Steps1.Value += (item2.CumulativeSteps - item3.CumulativeSteps);
I made a web application, and tested it locally. Everything worked fine so it was deployed to the hosting server.
After a few weeks some of the users started to experience the "Object reference not set to an instance of an object" error.
This is currently happening only in the chrome browser(on other browsers the application starts normally for them), and also if they use the incognito mode in chrome the application is opening normally.
Here is the whole error message, unfortunately i didn't get the line in code where the error is, even though i used
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. 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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
INAWebAppTest.SiteMaster.Page_Load(Object sender, EventArgs e) +884
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
I don't know if this can be because of a newer version of application being deployed on the server, in combination with the users cookies?
If so, can You please advise what i could try to correct this issue. I can't ask all of the users to clean up their browser history and cookies, there are too many of them, and it wouldn't solve this issue if it happened again in the future.
Here is the code from the site master:
public partial class SiteLogin : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["userInfo"] != null)
{
Response.Cookies.Set(Request.Cookies["userInfo"]);
Response.Cookies["userInfo"]["lastVisit"] = DateTime.Now.ToString();
Response.Cookies["userInfo"].Expires = DateTime.Now.AddDays(7);
if (Server.HtmlEncode(Request.Cookies["userInfo"]["userName"]) == null)
{
Response.Redirect("~/Account/login.aspx");
}
if (Server.HtmlEncode(Request.Cookies["userInfo"]["role"]).Equals("3"))
Response.Redirect("~/Form/Progress.aspx");
if (Server.HtmlEncode(Request.Cookies["userInfo"]["role"]).Equals("2"))
Response.Redirect("~/CForm/CHome.aspx");
if (Server.HtmlEncode(Request.Cookies["userInfo"]["role"]).Equals("1"))
Response.Redirect("~/AForm/AHome.aspx");
}
}
}
}
Here is the code from global.asax page:
protected void Session_Start(object sender, EventArgs e)
{
string sessionId;
if (Session.SessionID!=null)
sessionId = Session.SessionID;
else
{
SmtpClient client = new SmtpClient();
client.Port = xxx;
client.Host = "xxx.xxx.xxx.xxx";
client.EnableSsl = false;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("");
MailMessage mm = new MailMessage();
mm.From = new MailAddress("xxx", "xxx");
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mm.Subject = "Null object";
mm.IsBodyHtml = true;
mm.To.Add("xxx");
string body = "null";
mm.Body = body;
try
{
client.Send(mm);
}
catch
{
}
}
In the first version of the application the global.asax was empty, but there were some problems with session being flushed, so I googled and found that the solution is this line of code:
string sessionId = Session.SessionID;
This fixed that issue, but since some users were having the problem mentioned in this subject, i added some code around so that i get a message if the session variable isn't found. I never received this mail, so i don't think the problem is there.
Thank You for the help!
We don't really have enough information to tell you exactly what went wrong, all I can tell from the trace you've included is that the exception is being thrown in your master page's Page_Load method.
Take a look through this method and check for any point where you access properties of an object without checking that the object exists. Common culprits in my experience are pulling things out of the session or cookies collection and trying to use them without checking that you didn't just pull a null value out. The best way to fix it would be if you could replicate this problem yourself by using chrome and stepping through the Page_Load method.
EDIT: After seeing your posted source, I don't see anything that immediately stands out as breaking chrome compatibility, you have some weird cookie logic imo but nothing breaking. My only suggestion would be for you to try to replicate this further, and add more logging into your solution so that when your users hit this exception you can get more information.
One technique I've used in the past was to deploy the site in debug mode with all the .pdb files in place, and use something like this:
var stack = new StackTrace(exception, true);
// Get the top stack frame
var frame = st.GetFrame(0);
// Get the line number from the stack frame
var line = frame.GetFileLineNumber();
then log that value. It should give you the line number that the exception was thrown on, although as I said nothing in your code stands out as being wrong to me, so I'm not totally sure.
For the last 2 weeks I have a case that I can't figure it out, maybe you guys already passed through the same problem or ear/read about it and can help me.
I have an ASP.NET Project that I run on my machine and other machines fine, every time I try to temper the QueryString I get an error that is been thrown by the System.Exception
problem is, in this particular machine (witch is in Holland) the Application_Error never catches the Exception, it saves the Exception message to the log (as in my application should be done) but it does not "break" the web application... it just continues!
How and what can make this possible?
for an example sake, this is my webpage (HttpCache canot be invoked like this, but is only to point that I'm using the Web.HttpCache object)
if( Request.QueryString["user"] != HttpCache["MYAPP-user"] ) {
myApp.DebugWrite("User was tempered.");
throw System.Exception("User was tempered.");
}
and in global.asax I have
...
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
if (Server.GetLastError() != null)
{
Exception objErr = Server.GetLastError().GetBaseException();
String url = Request.Url.ToString();
String msg = objErr.Message;
String trc = objErr.StackTrace.ToString();
Response.Clear();
StringBuilder html = new StringBuilder();
// fill up html with html code in order to present a nice message
Response.Write(html.ToString());
Server.ClearError();
Response.Flush();
Response.End();
}
}
...
in my test machines, I always get the html with the error message, as well the message in the log... in this particular machine, I only see the error in the log, but the application continue!!!
web.config is exactly the same as in all machines and this web application runs on .NET 2.0
What can it be?
Comment out the Response and Server.ClearError() part in your code:
//Response.Clear();
StringBuilder html = new StringBuilder();
// fill up html with html code in order to present a nice message
Response.Write(html.ToString());
//Server.ClearError();
//Response.Flush();
//Response.End();