ActivityNotFoundException for unknown reasons - c#

I'm starting to learn Xamarin, and I'm stuck in this problem. There is an exception thrown
Android.Content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=Chris...
https://www.removeddit.com/r/greentext/comments/a9rwbb/anon_goes_to_christmas_dinner/eclyp8c
Background: I'm developing a small personal project that opens removeddit in a browser automatically from my phone through reddit.
The issue is it throws the exception when I run the code below. That probably would have been my mistake and I haven't googled enough. But surprisingly when I copy-paste and override the output link with the URI produced by the three lines of code in pre-processing, as observed in the debug line, the browser opens up with the right webpage.
Current Code that doesn't work:
//Let's call it pre-processing
string outputLink = inputLink.Substring(inputLink.LastIndexOf(' '));
outputLink = outputLink.Replace("reddit", "removeddit");
outputLink = outputLink.Trim();
Log.Info("DebugTag", outputLink);
Uri uri = Uri.Parse(outputLink);
var intent = new Intent(Intent.ActionView, uri);
StartActivity(intent);
Replacement code that makes it work in place of pre-processing:
string outputLink = "https://www.removeddit.com/r/greentext/comments/a9rwbb/anon_goes_to_christmas_dinner/eclyp8c"
I absolutely have no idea what the mistake might be and I'm completely baffled.
EDIT: Added exception I'm observing.

Related

iOS iCloud failing to write with, Couldn't get container configuration from the server error

I have one app that I wrote already reading from and writing to the iCloud. I am essentially using the same code in my new app to do the same thing, but for some reason it will not work, giving me the following error, "Couldn't get container configuration from the server". Let me clarify, with this new app it does puts an entry in iCloud under manage storage, but instead of being under the name of my app, it is under adhoc.
Here is the line in my info.Plist,
Here is the line from my Entitlements,plist
lastly, here is my identifier defined on the apple developer site,
I have verified and reverified that everything is pointing to the correct thing so I am baffled. Any help would be much appreciated.
EDIT I guess what it is doing is writing file to my phone, but when it goes to save data to it, it fails with this message, Here is my call to save the data.
CKRecordID recordID = new CKRecordID(strDate);
await Task.Delay(200);
// Save it to iCloud
await pvc.SaveToiCloud(newRecord);
Here is my code to save the record,
public async Task SaveToiCloud(CKRecord newRecord)
{
ThisApp.PrivateDatabase.SaveRecord(newRecord, (record, err) =>
{
Edit:
I was thinking that possibly the number of nodes I had was too many, so I took out the "dist" one you see below, but that did not help. I thought maybe that was why I was seeing module name of adhoc under icloud on my phone, but I guess I was wrong.
Old:
New:
Edit
I have been doing more digging and found that this line of code is actually the one throwing the error.
File.WriteAllText(Path.Combine(filePath.Path, name + date), "Test");
The name and date contain correct values and the path looks fine to me... I guess... Don't know actually how it should look. Here is how the file path is getting set right above this call,
NSUrl filePath = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null).Append("Documents", true);
If anyone could offer any advice, I would be most appreciative.
So, I finally figured out the issue and it works like a champ now. The issue was the case in my bundle id in my info.plist. In CloudKit the DB name was all lower case, but my bundle Id in my info.plist, had AdHoc as my last node instead of adhoc as was in the CloudKit. You might say, what does the bundle Id have to do with the iCloud name, and actually I am not really sure, but I noticed that it was taking the case of that last node from my Bundle Id, not the case specified in the iCloud definition as I have shown above. Hope this helps someone who is struggling with a similar issue Have a great day!

Is there reason why I always have Tweetinvi.Exceptions.TwitterException: Forbidden error?

I am trying to make Twitter bot which job is to, when run, upload picture of Snoop Dog with quote and few hashtags. Problem is when I run my code, it throws Tweetinvi.Exceptions.TwitterException: Forbidden error.
I have tried searching for fix, but only thing I have found was just answers for meaning of error. Here is a part of code (rest are quotes, APIs and Tokens).
byte[] ImageBytes = File.ReadAllBytes("snoop.jpg");
TwitterClient UserClient = new TwitterClient(APIKey, APISecret, AccessToken, AccessSecret);
IMedia ImageIMedia = await UserClient.Upload.UploadTweetImageAsync(ImageBytes);
ITweet TweetWithImage = await UserClient.Tweets.PublishTweetAsync(new PublishTweetParameters(SnoopQuotes[RandNum.Next(10)] + "#ZemanNaUlici #SSPSNotGood #CyberMeansPrestige") { Medias = { ImageIMedia }});
Error is show here:
IMedia ImageIMedia = await UserClient.Upload.UploadTweetImageAsync(ImageBytes);
I would have loved some help, thank you.
PS: I am here for first time and english is not my primary language, so sorry if there are some mistakes.
I faced the same thing and found this video had all the answers.
https://youtu.be/aOlp3vXohB0
You need to upgrade your application in the developer portal to "Elevated", enable read/write on your posts and regenerate the API keys.

Null Reference Exception when calling iText7 PdfAcroForm.GetAcroForm() in .Net Core 3.1 class library

I am working on converting an application to .Net Core 3.1, and in my class library I am generating a PDF form from an existing template, and filling that form with data. In ITextSharp, the predecessor to IText7, the PdfAcroForm static method ".GetAcroForm()" worked perfectly, but in the current version of iText7 (7.1.12) a Null Reference Exception is thrown. I have followed the documentation to the best of my ability, but I am unsure how to continue. Any suggestions would be appreciated.
NOTE: The template path exists, the new document shows that it has been filled properly, and it is impossible to "new" a PdfAcroForm, you are required to use the static .GetAcroForm() method.
A null check will not solve this issue, as the object should never be null. The documentation indicates that the .GetAcroForm() method will create a new form if the parameter "createNotExist" is set to true, which I have done here.
I have researched and have located an issue on the iText GitHub that indicates that this issue was "fixed" around a year ago: https://github.com/itext/itext7/pull/44#issue-351612749
The following is the method which prepares the forms:
public string DocumentGenerator(string templatePath, FormFieldSet[] formFieldSet, bool useSpecailOutputPath)
{
if(!File.Exists(templatePath))
{
throw new Exception("The template file provided does not exist: MC-071(iText)");
}
string newFile = useSpecailOutputPath ?
m_SpecialOutputPath :
Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";
try
{
PdfDocument newDocument = new PdfDocument(new PdfReader(templatePath), new PdfWriter(newFile));
PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(newDocument, true); // <=== Exception Thrown Here
foreach (FormFieldSet fs in formFieldSet)
{
acroForm.GetField(fs.FieldName).SetValue(fs.FillValue);
}
// Sets form flattening
acroForm.FlattenFields();
// Closes and writes the form
newDocument.Close();
return newFile;
}
catch { return string.Empty; };
}
Any suggestions would be greatly appreciated
I had the same problem, and after digging down all the way to iText7's internal objects and methods, I finally "solved" my problem.
Apparently iText has some internal errors/exceptions that they are just sort of "skipping" and "pushing past", because I realized by accident that I had "Enable Just My Code" in Visual Studios disabled, and so my system was trying to debug iText7's code as well as mine. The moment that I re-enabled it in my Visual Studio settings (Tools > Options > Debugging > General > Enable Just My Code checkbox), the problem magically went away.
So I spent four hours trying to troubleshoot a problem that was in THEIR code, but that they apparently found some way to work around and push through the method anyways even on a null reference failure.
My convert to PDF function is now working just fine.
Just an update to anyone looking for this issue. This is a known issue and is fixed in the current development branch. You are safe to bypass the exception in visual studio until it is corrected. This has no negative impact on the functionality and is the result of a misplaced return in the original iText7 source.

Sudden Problems With Dynamic Not Working On (Only) My Machine

My basic setup is this:
//caller
dynamic thingThatEndsUpBeingAJObject = JsonConvert.DeserializeObject(await httpClientResponse.Content.ReadAsStringAsync());
var parsedThing = Parse(thingThatEndsUpBeingAJObject);
//elsewhere...
private async Task<ParsedThing> Parse(dynamic json)
{
dynamic referenceToThingIWant = json.ThingIWant;
return new ParsedThing{ SomeProp = referenceToThingIWant; }
}
...where I end up getting a RuntimeBinderException on the reference to json.ThingIWant.
Oddly, if I put a watch on:
((JObject)json)["ThingIWant"]
I can see darn well that it's there!
Even more perplexing is that the code runs fine on everyone else's machine (and I believe it ran fine on mine till days ago)!
What on earth could cause such a strange quirk?!?
I've gone as far as restarting the computer, FWIW.
Specific error/stack trace is:
'Newtonsoft.Json.Linq.JObject' does not contain a definition for 'ThingIWant'
at Microsoft.CSharp.RuntimeBinder.RuntimeBinderController.SubmitError(CError pError)

OpenAl and Alut for making a Sound Manager

I have been at this for quite a while. I am using C# for Serious Game Programing, and am working on the SoundManager code found in Chapter 9 of the book, if you want an exact reference. The Code is setting up a sound manager using OpenAl, and I am having a problem with the Alut interface (if that is the right word for what it is). Here is the code that I am working on:
public void LoadSound(string soundId, string path)
{
int buffer = -1;
Al.alGenBuffers(1, out buffer);
int errorCode = Al.alGetError();
System.Diagnostics.Debug.Assert(errorCode == Al.AL_NO_ERROR);
int format;
float frequency;
int size;
System.Diagnostics.Debug.Assert(File.Exists(path));
IntPtr data = Alut.alutLoadMemoryFromFile(path, out format, out size, out frequency);
int errorCode2 = Alut.alutGetError();
//string errorCodeString = Alut.alutGetErrorString(errorCode2);
//System.Diagnostics.Debug.Assert(errorCode2 != Alut.ALUT_ERROR_NO_ERROR);
//System.Diagnostics.Debug.Assert(data != IntPtr.Zero));
//System.Diagnostics.Debug.Write(errorCode2);
Al.alBufferData(buffer, format, data, size, (int)frequency);
_soundIdentifier.Add(soundId, new SoundSource(buffer, path));
}
The issue is this line right here: System.Diagnostics.Debug.Assert(data != IntPtr.Zero));. When this line is not commented out, it always fails. I did have it work, and do not know what I did to change it, and it stopped working. I have posted about this on another post here: Load sound problem in OpenAL
I have looked all over, and from what I can gather, the issue is with the way that OpenAl is working on my system. To that end, I have uninstalled the Tao Framework that I am using to run OpenAl, and reinstalled. I have also done a system restore to as many points as I have back. I have thought about nuking my whole system, and starting fresh, but a want to avoid this if I can.
I Also have found this link http://distro.ibiblio.org/rootlinux/rootlinux-ports/more/freealut/freealut-1.1.0/doc/alut.html#ErrorHandling that has helped me understand more about Alut, but have been unable to get an alut.dll from it, and cannot get any errors to display. This code:
int errorCode2 = Alut.alutGetError();
//string errorCodeString = Alut.alutGetErrorString(errorCode2);
//System.Diagnostics.Debug.Assert(errorCode2 != Alut.ALUT_ERROR_NO_ERROR);
System.Diagnostics.Debug.Write(errorCode2);
Is my attempt to find out the exact error. If I write the code like:
int errorCode2 = Alut.alutGetError();
//string errorCodeString = Alut.alutGetErrorString(errorCode2);
System.Diagnostics.Debug.Assert(errorCode2 != Alut.ALUT_ERROR_NO_ERROR);
System.Diagnostics.Debug.Write(errorCode2);
I may be using the code all wrong to the find the exact error, as I am still learning c#.
Here is what I am looking for:
1)Is this a syntax error or an error with my system
2)If it is an error in my system, are there files that I am not removing when I try to do an uninstall of OpenAL to refresh all the files.
3)How do I get the alutGetError() code to display in such a way that I can actually read what it is.
Thank you for any help beforehand.
I recently ran into the same problem while going through that book and was able to figure it out by logging the error to the output window, notice I through the console.writeline in there.
After doing that I checked the output window which gave me the error code 519. After looking all over I saw a few forum posts recommending I re-install openAl to fix this issue which did the trick, all the links I found didn't work to the download so I had to hunt around but softTonic had the one that worked for me on my windows 7 machine http://openal.en.softonic.com/download
IntPtr data = Alut.alutLoadMemoryFromFile(path, out format, out size, out frequency);
var error= Alut.alutGetError();
Console.WriteLine(error);
//System.Diagnostics.Debug.Assert(data != IntPtr.Zero);
Hope this helps,
helpdevelop

Categories

Resources