I am writing CD/DVD using IMAPI with C#.NET windows application.
The data I write on CD contains one executable file (test.exe) which is also developed with C#.NET and virtualized (sandobx) using Turbo Virtualization Studio.
All data to be written on CD is placed in one folder (source path) on C drive.
Following is small code snippet: -
IStream stream = null;
try
{
System.Diagnostics.Debug.Print("Adding - " + thisFileItem.SourcePath);
if (thisFileItem.SourcePath != null)
Win32.SHCreateStreamOnFile(thisFileItem.SourcePath, Win32.STGM_READ | Win32.STGM_SHARE_DENY_WRITE, ref stream);
if (stream != null)
{
fileSystemImage.Root.AddFile(thisFileItem.DestPath + thisFileItem.DisplayName, stream);
}
}
finally
{
if (stream != null)
{
Marshal.FinalReleaseComObject(stream);
}
}
Call to "fileSystemImage.Root.AddFile" method while adding test.exe throws COMException -1062555360 "Internal file system error occurred." All other files add and write properly.
Exception Details: -
COMException -1062555360
Internal file system error occurred.
at ImapiInterop.IFsiDirectoryItem.AddFile(String path, IStream fileData)
at ImapiImplementation.CDWriter.objBackgroundWorker_DoWork(Object sender, DoWorkEventArgs e) in C:\.........\CDWriter.cs:line 405
If I put my source folder on some other location (Desktop or D drive), all writing process (including test.exe) happens fine without error.
I suspect the issue is due to virutalization but not sure.
Please help.
The error message returned by IMAPI is incorrect and that is why all confusion.
Refer following link.
social.msdn.microsoft.com
Following is the text copied from answer (from Dmitri) on above site: -
IMAPI supports the ISupportErrorInfo interface, and we are aware of
the issue of mismatching error messages in your scenario.
Internally, IMAPI creates rollback objects to undo add/remove file
actions. We've had an issue where the rollback action was created
prematurely, so after the return code for IFsiDirectoryItem::AddFile
was already set, the rollback action was to remove the file from the
image. Since the file hasn't been added, IMAPI_E_FSI_INTERNAL_ERROR
exception was thrown, which changed the IErrorInfo message to the one
you're seeing.
We are aware of this issue, and it will be fixed in the next release
of IMAPI. Unfortunately, it is not serious enough to be addressed in a
hotfix.
Related
Blank project repo with problematic code
I have the following code for querying all the supported Audio codec following this article using CodecQuery.FindAllAsync
try
{
var query = new CodecQuery();
var queryResult = await query.FindAllAsync(CodecKind.Audio, CodecCategory.Encoder, "");
var subTypes = queryResult
.SelectMany(q => q.Subtypes)
.ToHashSet();
// Other codes
}
catch (Exception ex)
{
Debug.WriteLine(ex);
throw;
}
As the documentation mentioned,
To specify that all codecs of the specified kind and category should be returned, regardless of what media subtypes are supported, specify an empty string ("") or null for this parameter.
For empty string "", it works for CodecKind.Video but not for Audio (for both CodecCategory of Encoder or Decoder). If I specify a subtype, then it does not crash, for example:
var queryResult = await query.FindAllAsync(CodecKind.Audio, CodecCategory.Encoder, CodecSubtypes.AudioFormatMP3);
What is strange about that is that even though I have a try/catch with generic Exception, the app just crashes through that one and show this instead:
I have tried restarting Windows, uninstall the UWP app and make a clean build. What is happening? How do I query all available audio codecs?
Update: after changing Debug setting, I could trace the error message:
Unhandled exception at 0x00007FFDCE5FD759 (KernelBase.dll) in ******.exe: 0xC0000002: The requested operation is not implemented.
After my testing, the content of this document is correct. When I set “” for the third parameter to find all audio codecs, the code works well. So there is not an error in this document.
You could choose the Debug options, and change Debugger type from Managed Only to Mixed. It won't fix your exception, but you can trace it with the debugger. You could refer to this reply to get more information.
I'm running into problems writing an application to batch load and export files in AutoCAD using a C#. I've received numerous errors listed below whenever I point to a folder full of .dxf files. I've been able to narrow the problem down to the point where I know it's only breaking on load. Sometimes it loads fine, others it will only load 3-4 files, and the rest of the time it will simply throw an error. The errors I'm seeing include but are not limited to FaultExecutionEngineError, NullExceptionError, IndexOutOfRange error, and the wonderful FATAL EXCEPTION error, which causes Autocad to crash as well.
Here is my code:
public class MyCommands
{
string folderPath = #"C:\Users\kdhyne\Desktop\New folder\";
// Modal Command with localized name
[CommandMethod("FileCycle", CommandFlags.Session)]
public void MyCommand() // This method can have any name
{
var acDocManager = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
string[] filesInDirectory;
Document acDoc = null;
filesInDirectory = Directory.GetFiles(folderPath, "*.dxf", SearchOption.TopDirectoryOnly);
foreach (string someFile in filesInDirectory)
{
acDoc = acDocManager.Open(someFile);
}
}
}
I've stripped this down as far as I can think. Hopefully someone can help. Thank you for reading.
Do a release build before opening it in AutoCAD and it seems to work fine! Apparently it wasn't compiling all the libraries into the debug build.
I'm using Windows 7's Shell Libraries to overwrite an existing library and add new paths to it, using the managed wrapper available through the Windows API Code Pack 1.1.
Every now and then, I can't seem to reproduce this in any way, a COMException is thrown while adding the paths to the library:
System.Runtime.InteropServices.COMException (0x80070497): Unable to remove the file to be replaced. (Exception from HRESULT: 0x80070497)
at Microsoft.WindowsAPICodePack.Shell.IShellLibrary.Commit()
at ... (local code from here on out)
The code is quite straightforward. The error is thrown on the Add method.
using ( var activityContext = new ShellLibrary( LibraryName, true ) )
{
Array.ForEach( dataPaths, p => activityContext.Add( p.LocalPath ) );
}
Is there a certain scenario where this exception is to be expected which I can reproduce/test for?
Assuming this is a bug in the shell libraries, I could just catch the exception and retry doing the operation a couple of times, although I'm hoping for a cleaner 'solution'.
I've made a console application which inserts data into a MySql backend, and reads the serial number from a hard disk
To do this i had to add References to MySql.Data and to System.Managment.
The way im running it is by copying the Debug directory from visual studio (i think this is the problem) and running the .exe file on the other machine.
When i run the application on another machine the stack trace error is:
PhDD >C:\Users\User\File\Indexer\WMI\Debug
Your key: 634685018347902535133
Exception getting SMART Object: reference not set to an instance of an object.
Exception in main thread: at System.ThrowHelper.ThrowArgumentOutOfRangeExcept
ion()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at WMITest.Menu.Run() in C:\Users\fps700\Music\WMITest\Menu.cs:line 49
Updated HDD Stats at28/03/2012 18:46:57
Am i correct in thinking this problem is because of the referencing ?
I've checked the methods by recompiling the same code on the other machine and it works, when the references are added through VS.
Can anyone guide me on how to resolve this issue ?
Cheers for reading.
P.S. i tried adding reference paths (by right clicking on the project, selecting options and then choosing Reference Paths and adding the two dll files)
Line 49
bool conversion = int.TryParse(smartData[1].ToString(), out temp);
After adding a fake int value just to make sure conversion isnt the error the new stack trace error is:
PhDD >C:\Users\bborisov\Dropbox\Indexer\WMI\Debug
Your key: 634685018347902535133
Exception getting SMART Object reference not set to an instance of an object.
Exception in main thread: at System.ThrowHelper.ThrowArgumentOutOfRangeExcept
ion()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at WMITest.Menu.Run() in C:\Users\fps700\Music\WMITest\Menu.cs:line 53
Updated HDD Stats at28/03/2012 19:00:24
line 53:
DBHandler.insertData(smartData[0].Trim(),
3, smartData[2], file.getKey());
Put code in to check validity of error situations which may be happening on the client pc but not the development one. You can handle the errors by either throwing an exception or handling it gracefully in a better way.
Here is the code which checks for error situations
if (smartData == null)
throw new Exception("Smart data is null; aborting");
if (smartData.Any() == false)
throw new Exception("Smart data instance is valid but has no elements; aborting");
bool conversion = int.TryParse(smartData[1].ToString(), out temp);
In the following code example... where filePath is: E:\[D]\My Collection (a folder generated by picasa when it archives media) works okay on XP (32-bit). I recent ran this on vista 64-bit... and ParseDisplayName errors with "Value does not fall within the expected range." All other folders (without the '[D]') work okay. Any help would be appreciated.
try
{
int cParsed = 0;
int pdwAttrib = 0;
string filePath = Path.GetDirectoryName(file);
pidlMain = IntPtr.Zero;
folder.ParseDisplayName(IntPtr.Zero,IntPtr.Zero,filePath,out cParsed,out pidlMain,out pdwAttrib);
}
catch (Exception ex)
{
Marshal.ReleaseComObject(folder);
throw ex;
}
This happens (irrespective of the code pack; you can repro it by using the shell API directly and getting the parsing name) on Vista when you select the folders in the Common File Dialog (or any type of Open dialog) from the left side tree view.
For e.g - using the example you mention - Code pack's sample. Run the sample, select browse, from the CFD, select your folder from the left side tree view. You will also get the same problem if you go inside the folder and then click on "Open". The parsing name that you get is:
c:\folder\folder (notice the duplicate folder).
This is a known issue in Vista... I am afraid there is no patch for it (or atleast that I am aware of - unless you switch to Win7 :-) )