I am trying to create and fill an h5 file within the application I am working on. I need to use HDF5DotNet. When I try to create a string datatype, I get the following exception:
H5T.copy: Failed to copy C_S1 with status -1
when I call H5T.copy(H5T.H5Type.C-S1).
I have no idea what it means and how this exception can occur. Any help would be useful.
Thanks!
Related
I have a C# program that is using QBFCv13 to create 46 customers in QuickBooks Pro 2014.
When the program runs, I get an exception with message "String too long.". I am guessing it's probably caused by one of the customer name is too long so I test the program to create 2 customers with one long name. This time I didn't get an exception. I get a response list with one response containing error code and the other response without error.
I am confused. Why in certain case I get an exception? The message doesn't contain any more message than "String too long". I am wondering if there is something else I can do to figure what is causing this "String too long" error.
Thanks.
Try enabling verbose logging and see if it tells you what the error is.
https://intuitpartnerplatform.lc.intuit.com/questions/177198-troubleshooting-sdk-issues
Using Windows Fax Service, I am trying to cancel a fax from the Windows Fax Console. According to this worthless documentation I need to pass in a value JC_Delete which appears that it is some enumeration, however, the documentation fails to leave out what it is or how to get it.
I found another MSDN article stating in the last sentence that these JC values are just constants which the user defines. Finally, I found a forum post stating that it's just an enumeration in a C++ header file and the Microsoft guy showed the enumeration consisting of:
JC_UNKNOWN = 0
JC_DELETE = 1
JC_PAUSE = 2
JC_RESUME = 3
JC_RESTART = JC_RESUME
I just tried plugging in numbers, 0 or 1 since the method calls for an int and then I receive an exception
COM error:
the handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
Here is my bit of code. I am able to get the FaxJob object just fine. It's just calling the SetStatus() method that bombs.
var job = this.getFaxJobsInQueue().Where(j => j.JobId == JobId).Single();
job.SetStatus(1);
Arg!! Found the problem! It was very simple! I forgot to connect to the fax console. Apparently that is what the handle is invalid was indicating. My problem was in the method that returned all the jobs connected and disconnected. Once I had the FaxJob object, I was suppose to connect again. Here is my updated code:
var job = this.getFaxJobsInQueue().Where(j => j.JobId == JobId).Single();
this.objFaxServer.Connect(faxServerConnectionString);
job.SetStatus(1);
this.objFaxServer.Disconnect();
I'm trying to save a collection where a store a diagnostic log temporarily when navigating away from my app - I've looked at other sample code and it seems pretty basic as I've done below:
Saving:
PhoneApplicationService.Current.State["DiagnosticLog"] = DiagnosticLog;
Loading:
if (PhoneApplicationService.Current.State.ContainsKey("DiagnosticLog"))
DiagnosticLog = (ObservableCollection<DiagnosticLogEntry>)
PhoneApplicationService.Current.State["DiagnosticLog"];
However I get this error:
A first chance exception of type
'System.Runtime.Serialization.InvalidDataContractException' occurred
in System.Runtime.Serialization.dll
Any suggestions please?
Usually, when this happens, it means you do not have a default public constructor on your Diagnostic class (or one of it's contained classes).
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 C#, System.IO.File.Delete(filePath) will either delete the specified file, or raise an exception. If the current user doesn't have permission to delete the file, it'll raise an UnauthorizedAccessException.
Is there some way that I can tell ahead of time whether the delete is likely to throw an UnauthorizedAccessException or not (i.e. query the ACL to see whether the current thread's identity has permission to delete the specified file?)
I'm basically looking to do:
if (FileIsDeletableByCurrentUser(filePath)) {
/* remove supporting database records, etc. here */
File.Delete(filePath);
}
but I have no idea how to implement FileIsDeletableByCurrentUser().
The problem with implementing FileIsDeletableByCurrentUser is that it's not possible to do so. The reason is the file system is a constantly changing item.
In between any check you make to the file system and the next operation any number of events can and will happen. Including ...
Permissions on the file could change
The file could be deleted
The file could be locked by another user / process
The USB key the file is on could be removed
The best function you could write would most aptly be named FileWasDeletableByCurrentUser.
Have you tried System.IO.File.GetAccessControl(filename) it should return a FileSecurity with information about the permissions for that file.
Strictly speaking, an UnauthorizedAccessException means that the path is a directory, so you can use a System.IO.Path.GetFileName(path) type command and catch the argument exception.
But if you want a more holistic solution, use System.IO.File.GetAccessControl as mentioned by Dale Halliwell
As stated above.
Lookup the file permissions and compare with the user who is running the application.
You could always use this aproach as well
bool deletemyfile()
{
try
{
...delete my file
return true;
}
catch
{
return false;
}
}
if it returns false you know it failed if it returns true then.. it worked and file is gone. Not sure what you're after exactly but this was the best I could think of
Of course you can check ReadOnly flags using System.IO and probably ACL security on the file combined with the current user too, but like Mehrdad writes in his comment it would never be full-proof in all cases. So you would need exception handling for the exceptional case at all times (even if its just a top-level catch-all, that logs/shows an "unexpected problem" and kills your application).
You should get the access control list (ACL) of that file.
But this doesn't necessarily mean you could actually delete it because the readonly flag could still be set or another program has locked the file.
Seems like it would be easier to do things in the order of:
Get whatever information you need about the file in order to do the other parts (delete database data, etc)
Try to delete the file
If you successfully delete the file, then carry out the rest of the "cleanup" work. If you don't successfully delete it, return/handle the exception, etc.