c# firestore - Additional information: Path cannot contain empty elements - c#

I'm trying to check if a document exists from my firestore DB but am getting an error before it checks if it exists so I'm a bit confused. I would think my documentsnapshot would return null after the .GetSnapshotAsync() call first however it is just tripping an error and not able to get to the if (docSnapshot.Exists) line.
Context: I am switching over from realtime database to Firestore so the paths are not the same. In this case, lastPath is not empty but it is a realtime database path. Therefore, the line is checking for a realtime database path and is expected to return false.
lastPath = MyCollection/Projects/6f8ebcf7-231f-47e5-ac72-2707cd38ae8f/
The error that occurs: Additional information: Path cannot contain empty elements
So far, I've tried:
The following code is:
DocumentReference documentReference = firestoredb.Document(lastPath); // <<-- throws error not able to continue
and
DocumentSnapshot docSnapshot = await firestoredb.Document(lastPath).GetSnapshotAsync(); // <<-- Also throws error.
Here is the code that follows:
if (docSnapshot.Exists)
{
// do this
}
else if (!docSnapshot.Exists)
{
// do this instead.
}
I can only think of doing a try-catch but I am hoping there is a better way to check if the document exists.
I checked the docs but I keep getting the error and the other posts I've found on SO show mostly for android.
Any and all help is appreciated.

Related

Error TF51635 Occurred while importing GlobalList using TFS REST API

I am importing GlobalList using TFS Rest API,
but getting the error below:
The server operation failed. (TF51635: There are duplicate temp IDs in
the Update XML. Parameter name: updateElement).
Sample code:
string text = System.IO.File.ReadAllText(SavDir + #"\Customer_Cleanze.xml");
try
{
workItemStore.ImportGlobalLists(text);
}
catch(Exception e){
Console.WriteLine(e.Message);
Console.WriteLine("Error Occured");
}
This XML list contains about 3K records. The strange thing is that when I try to import individual list item, it works fine means list item does not have an issue.
There is no documentation on Net, however, the similar issue posted here:
Can someone please help me in telling what is the wrong happening here?

Application crashes on element reader (pdftron)

I have an issue with pdftron, where opening a certain file, will cause our application to crash with following error:
An unhandled exception of type 'pdftron.Common.PDFNetException' occurred in PDFNet.dll
Additional information: Exception:
Message: Missing resource
Conditional expression: res
Filename : ContentResources.hpp
Function : trn::PDF::ContentResources::GetResource
Linenumber : 26
In our code: it's in the following line that the error occurs:
while ((element = elReader.Next()) != null)
When doing try/catch, we see that the only thing missing from the page is the text that's written diagonally on that page. Does this have anything to do with a missing font maybe ? Don't mind the cursor in the picture, it doesn't know where to go with the text missing.
I can send the pdf file on request.
PDF File
If you are not on the latest version of PDFNet, 6.7.1, then I would first try against that, as the issue might have been resolved already.
Otherwise, since the issue is document specific, you would need to provide that, by either sharing here, or sending to pdftron support.

Error while executing script for a TableObject located at the PageFooter section

We have a report that displays at the PageFooter which payment way the customer used to pay an order, in that area we have three other TableObjects that are working correctly, but there's one that executes a script to build manually the TableObject, the problem we located is when it executes that script it fails showing the message StackOverflowException in System.Drawing.dll
The message on top means the report generation is executing.
The script that I located it fails is this one, if this script is not executing the report displays correctly but without the information we want to display in that TableObject
private void TableModalidadPago_ManualBuild(object sender, EventArgs e)
{
// get the data source by its name
DataSourceBase rowData = Report.GetDataSource("DOCUMENTO_MODALIDAD_PAGO");
// init the data source
rowData.Init();
if (rowData.RowCount == 0)
{
TableModalidadPago.Visible = false;
return;
}
// print the first table row - it is a header
TableModalidadPago.PrintRow(0);
TableModalidadPago.PrintColumns();
TableModalidadPago.PrintRow(1);
TableModalidadPago.PrintColumns();
// now enumerate the data source and print the table body
while (rowData.HasMoreRows)
{
// print the table body
TableModalidadPago.PrintRow(2);
TableModalidadPago.PrintColumns();
// go next data source row
rowData.Next();
}
TableModalidadPago.CanBreak = false;
TableModalidadPago.CanGrow = true;
}
It fails at line
TableModalidadPago.PrintRow(0);
And if I put the TableObject in other section that is not the PageFooter it works perfectly.
Anyone knows if there's any restriction to execute code at PageFooter or if there's any error at the provided script?
I already posted this information in FastReports forum but still no answer(Link)
Edit: I also created a ticket in FastReports Support centre and still no answer...
Edit2: 24/06/2016 today I saw they published a new version of the FastReports.Net (2016.3 previous was 2016.2) and I downloaded and install it, after cleaning up my project and tried again, the error still ocurring, with this new version the program just unexplectly closes and doesn't display any error message, I updated my ticket with support center
Thanks.
The stack overflow error suggests that the while loop may be infinite. Could it actually be failing at the line
TableModalidadPago.PrintRow(2);
Perhaps you need to remove rows from rowData object once you've printed them?

Object reference not set to an instance of an object. BitShuva

Hi I've downloaded some source code and I'm having some major issues with it straight out of the box. I've not been able to get an answer from the developer and I've not seen anyone else ask this question, but I've looked and looked and looked and I've no idea what's going wrong.
I keep getting this error:
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:
Line 157: // Expected ID is standard Raven ID: "songs/4321"
Line 158: const string expectedIdPrefix = "songs/";
Line 159: if (song.Id.StartsWith(expectedIdPrefix, StringComparison.OrdinalIgnoreCase))
Line 160: {
Line 161: throw new ArgumentException("ID wasn't in the expected format.");
Visual Studio highlights this bit of code. (denoted by ** **)
using (var session = Get.A<IDocumentStore>().OpenSession())
{
var songFiles = Directory
.EnumerateFiles(Server.MapPath("~/content/sample/music"), "*.mp3")
.Select(f => new
{
Song = new Song(Path.GetFileName(f)),
FilePath = f
})
.ToArray();
songFiles.ForEach(async f => **await f.Song.UploadMp3ToCdn(f.FilePath));**
if (!session.Query<Song>().Any())
{
songFiles.ForEach(s => session.Store(s));
session.SaveChanges();
}
}
Have you tried inspecting songFiles within the debugger? The error seems to suggest that either f.Song or f.FilePath is null/uninitialised.
Found the issue, it's trying to upload music to the CDN specified in the web.config file, and it's looking for the ID of the song. The ID must be generated by Raven database first, and it's trying to pull the ID prior.
Issue Fixed.

ActiveDirectory error 0x8000500c when traversing properties

I got the following snippet (SomeName/SomeDomain contains real values in my code)
var entry = new DirectoryEntry("LDAP://CN=SomeName,OU=All Groups,dc=SomeDomain,dc=com");
foreach (object property in entry.Properties)
{
Console.WriteLine(property);
}
It prints OK for the first 21 properties, but then fail with:
COMException {"Unknown error (0x8000500c)"}
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.PropertyEnumerator.get_Entry()
at System.DirectoryServices.PropertyCollection.PropertyEnumerator.get_Current()
at ActiveDirectory.Tests.IntegrationTests.ObjectFactoryTests.TestMethod1() in MyTests.cs:line 22
Why? How can I prevent it?
Update
It's a custom attribute that fails.
I've tried to use entry.RefreshCache() and entry.RefreshCache(new[]{"theAttributeName"}) before enumerating the properties (which didn't help).
Update2
entry.InvokeGet("theAttributeName") works (and without RefreshCache).
Can someone explain why?
Update3
It works if I supply the FQDN to the item: LDAP://srv00014.ssab.com/CN=SomeName,xxxx
Bounty
I'm looking for an answer which addresses the following:
Why entry.Properties["customAttributeName"] fails with the mentioned exception
Why entry.InvokeGet("customAttributeName") works
The cause of the exception
How to get both working
If one wants to access a custom attribute from a machine that is not
part of the domain where the custom attribute resides (the credentials
of the logged in user don't matter) one needs to pass the fully
qualified name of the object is trying to access otherwise the schema
cache on the client machine is not properly refreshed, nevermind all
the schema.refresh() calls you make
Found here. This sounds like your problem, given the updates made to the question.
Using the Err.exe tool here
http://www.microsoft.com/download/en/details.aspx?id=985
It spits out:
for hex 0x8000500c / decimal -2147463156 :
E_ADS_CANT_CONVERT_DATATYPE adserr.h
The directory datatype cannot be converted to/from a native
DS datatype
1 matches found for "0x8000500c"
Googled "The directory datatype cannot be converted to/from a native" and found this KB:
http://support.microsoft.com/kb/907462
I have the same failure. I´m read and saw a lot of questions about the error 0x8000500c by listing attribute from a DirectoryEntry.
I could see, with the Process Monitor (Sysinternals), that my process has read a schema file. This schema file is saved under
C:\Users\xxxx\AppData\Local\Microsoft\Windows\SchCache\xyz.sch.
Remove this file and the program works fine :)
I just encountered the issue and mine was with a web application.
I had this bit of code which pulls the user out of windows authentication in IIS and pulls their info from AD.
using (var context = new PrincipalContext(ContextType.Domain))
{
var name = UserPrincipal.Current.DisplayName;
var principal = UserPrincipal.FindByIdentity(context, this.user.Identity.Name);
if (principal != null)
{
this.fullName = principal.GivenName + " " + principal.Surname;
}
else
{
this.fullName = string.Empty;
}
}
This worked fine in my tests, but when I published the website it would come up with this error on FindByIdentity call.
I fixed the issue by using correct user for the app-pool of the website. As soon as I fixed that, this started working.
I had the same problem with a custom attribute of a weird data type. I had a utility program that would extract the value, but some more structured code in a service that would not.
The utility was working directly with a SearchResult object, while the service was using a DirectoryEntry.
It distilled out to this.
SearchResult result;
result.Properties[customProp]; // might work for you
result.Properties[customProp][0]; // works for me. see below
using (DirectoryEntry entry = result.GetDirectoryEntry())
{
entry.Properties[customProp]; // fails
entry.InvokeGet(customProp); // fails as well for the weird data
}
My gut feel is that the SearchResult is a little less of an enforcer and returns back whatever it has.
When this is converted to a DirectoryEntry, this code munges the weird data type so that even InvokeGet fails.
My actual extraction code with the extra [0] looks like:
byte[] bytes = (byte[])((result.Properties[customProp][0]));
String customValue = System.Text.Encoding.UTF8.GetString(bytes);
I picked up the second line from another posting on the site.

Categories