DeleteAsync() Causes FileNotFoundException in C# .NET for Windows Store - visual-studio-2012

I'm having a problem where I'm trying to delete a folder that I've created asynchronously. I can't seem to use System.IO.File to delete synchronously because Visual Studio Express claims that this does not exist. When I use DeleteAsync(), the folder deletes just fine, but it also throws a FileNotFoundException, which is a problem because it causes my program to fail, even though the folder gets deleted successfully. It's been giving me issues for days.
I've initialized the folder like this
StorageFolder zip_contents_folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Zip Contents", CreationCollisionOption.ReplaceExisting);
and, after extracting zip files to it, I delete it later by using
try
{
await zip_contents_folder.RenameAsync("trashfile2.xml", NameCollisionOption.GenerateUniqueName);
await zip_contents_folder.DeleteAsync();
}
catch (Exception e_deletezipfolder)
{
System.Diagnostics.Debug.WriteLine(e_deletezipfolder.ToString());
}
EDIT:
This is the output to the console. It's happening right after my 3rd party DLL is loaded
'Indigo.exe' (Managed (v4.0.30319)): Loaded 'D:\Skydrive\Visual Studio Projects\eBook\Indigo\bin\Debug\AppX\Ionic.Zip.DLL'
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
Does anyone know a workaround for this problem?

Related

Unexpected error occurrs when I try to acess local storage in my extension

I'm updating the extension I wrote few months ago and just when I finished I realized that local storage in loader.js (file which is loaded on each visit to the specific page) returns:
Error: "An unexpected error occurred."
It is the part where I try to load informations from the local storage:
chrome.storage.local.get('setting-one', result => {
if (chrome.runtime.lastError) {
throw new Error(chrome.runtime.lastError); // error is thrown
...
This worked without problems in the past but now it doesn't. This is the case for Firefox. On Chrome, extension doesn't work either and doesn't return any error from loader.js. I'm not sure if API has changed or some new changes were introduced regarding access to local storage. I was looking for the solution on the web but there is nothing regarding this problem.
On the page of extension I can set and get all informations from storage without any problem.
Seems like your problem is resolved, but there is one bug in Firefox which I encountered few times. It might have been what happened to you although I can't reproduce it today for your case. I did loose some time today on a very similar situation with the same error message.
The error: Error: An unexpected error occurred is seen sometimes on Firefox, after successful call of a method,
if you also define a catch method and when you have DevTools open and turned on both Pause on exceptions and Pause on caught exceptions
Today I had this on the end of a method I used:
return browser.storage.local.set(storedObject)
.then(() => console.log('Util_WebExt.saveToStorage(): '+valueName+' stored.'))
.catch(e => console.error('Util_WebExt.saveToStorage(): '+valueName+' | error: '+e));
I did try it on get() as was your case, but the error did not show.
Also, it does not show on storage.sync, only storage.local
On other occasions, I had the same behavior with a different case, different method. Can't remember, but there is a post on stackoverflow where it's claimed that this is a feature and not a bug. I don't see how though. It was probably misunderstood.

How to find out why debug shows many exceptions in service fabric

I am running a application I made in service fabric on the local dev cluster.
when debugging and seeing the output, its filled with
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
everything is green and I havent found anything that dont work as expected. So what exactly do I do to find out what it is that is an InvalidOperation :) ?
Checked event logs and diagnostic events and no errors are shown.
It is probably catched and handled inside SFA, if it would be serious it would be rethrown so I would not worry about it too much.
Might have to do with the fact that it is the local dev environment and certain operations are not valid in a non-azure / on-premises installation environment.
A local dev environment for example lets you simulate a 5 node cluster on a single machine. Any exceptions caused by that might be catched and if it is detected that it is a non-real world environment it could be handled in a different way.
I'm seeing exactly the same thing, but in production as well and agree that I don't think it's a problem, though it will impact performance.
I'll put a few more things in context to hopefully help other people who see the same thing.
Here's my code which works correctly and I don't see the exception being thrown all the way up.
Log.Information("About to record activity for {Machine}", machineId);
using (var tx = StateManager.CreateTransaction())
{
await map.AddOrUpdateAsync(tx, machineId, _ => new SystemInfo { LastSeenUtc = timestampUtc }, (_, info) =>
{
info.LastSeenUtc = timestampUtc;
return info;
}).ConfigureAwait(false);
await tx.CommitAsync().ConfigureAwait(false);
Log.Information("Just committed transaction {Tx}", tx.TransactionId);
}
Log.Information("Recorded activity for {Machine}", machineId);
And with the debug output window. I'm using serilog with the Serilog.Sinks.Debug sink to capture the output.
[07:48:27 INF] About to record activity for d6441d45e1834db7860c00a8074652f9
[07:48:27 INF] Just committed transaction 131489813076754311
[07:48:27 INF] Recorded activity for d6441d45e1834db7860c00a8074652f9
Exception thrown: 'System.InvalidOperationException' in Microsoft.ServiceFabric.Data.Impl.dll
Transaction 131489813076754311 is committing or rolling back or has already committed or rolled back
And I see the stack trace as
Everything else appears to be fine - but throwing exceptions is not great for performance.

'ViewBag' It may be inaccessible due to its protection level

MVC 5 vb web application
I created a entityFramework migrations where I have a class library for data entities and combined it with the AspNet Identity within the web application. No error so far. I created a IndentityDB that has the defaultConnection and updated the AccountController to point to the connection
(New UserStore(Of ApplicationUser)(New IndentityDB())))
seems to be right with no error on the build except for a enum issue in the classlibrary that I will fix later but I get a error:
'ViewBag' is not declared. It may be inaccessible due to its protection level.
A first chance exception of type 'System.InvalidOperationException'
occurred in System.dll A first chance exception of type
'System.Web.HttpException' occurred in System.Web.dll 'iisexpress.exe'
(CLR v4.0.30319: /LM/W3SVC/32/ROOT-1-130360312907627858): Loaded
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Services.Design\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Services.Design.dll'.
Cannot find or open the PDB file.
This error happens when I try to login on the home page and any other Authorized Controller

SoapHttpClientProtocol automatically retry after exception?

I am just curious about this. I am making a change in this project, that is using NetSuite web service, and sometimes it throws a SoapException at random, "Only one request may be made against a session at a time".
private NetSuiteService _service;
SessionResponse response = _service.login(passport); //if SoapException, retries??
Status status = response.status;
Reference.cs:
public partial class NetSuiteService :
System.Web.Services.Protocols.SoapHttpClientProtocol
My question is: If I am in debug mode, I trace this, and I hit F5, and it seems to automatically retry after exception is thrown (the code keeps running, with no try catch block implemented, no while loop) until successful (status.isSuccess == true). When I run it in release mode, as a windows service, the log shows it stops running after exception is thrown.
How is this possible? Is it better to catch this exception in a try catch block and retry?
NS Server refuses a request if its already processing one from the same user.
If you want to make sure that your request succeeds than you have to catch this exception and retry.
This was not the experience I had. We thought this related to netsuite sessions but turned out to be nothing to do with that at all and in fact was not even hitting netsuite (according to netsuite log)​​. Turned out we were trying to execute too many commands in a single request and it totally refused to send it to netsuite. Never seen this error before, may be it is a new thing with the new version!

Incorrect attribute value type Microsoft.Xrm.Sdk.OptionSetValue

While creating an Incident. I am facing this issue. I have created some incidents and it working fine but sometime it shows this exception "Incorrect attribute value type Microsoft.Xrm.Sdk.OptionSetValue".
How to trace which OptionSetValue throws an error.
I'm going to assume that you're creating these via a C# sdk call. I believe turning on server side tracing would tell you. The other option is if you can debug it locally, catch the exception and manually attempt to update each optionset attribute, one at a time until you find the culprit.

Resources