Using PuppeteerSharp, I am attempting to get the performance.timeOrigin value using the C# code below:
JToken performanceTimeOriginString = await _page.EvaluateFunctionAsync("JSON.stringify(performance.timeOrigin);").ConfigureAwait(false);
I have verified that this works in a JavaScript console:
However, when I run the above PuppeteerSharp code, I get the following exception:
System.AggregateException: One or more errors occurred. (Evaluation failed: SyntaxError: Unexpected token ';') ---> PuppeteerSharp.EvaluationFailedException: Evaluation failed: SyntaxError: Unexpected token ';'
at PuppeteerSharp.ExecutionContext.ExecuteEvaluationAsync(String method, Object args)
at PuppeteerSharp.ExecutionContext.RemoteObjectTaskToObject[T](Task`1 remote)
at PuppeteerSharp.DOMWorld.EvaluateFunctionAsync[T](String script, Object[] args)
--- End of inner exception stack trace ---
It was telling me to remove the semicolon (very odd), so I tried that but then got the below exception.
System.AggregateException: One or more errors occurred. (Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function) ---> PuppeteerSharp.EvaluationFailedException: Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function ---> PuppeteerSharp.MessageException: Protocol error (Runtime.callFunctionOn): Given expression does not evaluate to a function
at PuppeteerSharp.CDPSession.SendAsync(String method, Object args, Boolean waitForCallback)
at PuppeteerSharp.CDPSession.SendAsync[T](String method, Object args)
at PuppeteerSharp.ExecutionContext.ExecuteEvaluationAsync(String method, Object args)
--- End of inner exception stack trace ---
How can I use PuppeteerSharp to get the value of performance.timeOrigin?
You should use EvaluateExpressionAsync.
_page.EvaluateExpressionAsync("JSON.stringify(performance.timeOrigin)").ConfigureAwait(false);
Related
world! I just started with C# and I have a problem with changing working directory in ScriptCS shell. Basically every time I do :cd <my dir>, it prints this error in the console:
System.Exception: Argument is not a valid expression: <my dir> ---> Microsoft.CodeAnalysis.Scripting.CompilationErrorException: (1,3): error CS1525: Invalid expression term ''
at Microsoft.CodeAnalysis.Scripting.Script.CompilationError(DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.Scripting.Script.GetExecutor(CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Scripting.Script.Run(Object globals)
at ScriptCs.Engine.Roslyn.CSharpScriptEngine.GetScriptState(String code, Object globals)
at ScriptCs.Engine.Roslyn.CommonScriptEngine.Execute(String code, Object globals, SessionState`1 sessionState)
--- End of inner exception stack trace ---
at ScriptCs.Repl.Execute(String script, String[] scriptArgs)
How do I fix this? Thanks in advance for your help!
I have to use MessagePack to deserialize data returned from a web API (ASP.net), which was Serialized using the same package.
Used the following code
public async static Task<T> DeserializeAsync<T>(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException(nameof(stream), "Stream value cannot be null");
}
stream.Position = 0;
T deserialized = await MessagePackSerializer.DeserializeAsync<T>(stream, MessagePack.Resolvers.ContractlessStandardResolver.Options).ConfigureAwait(false);
return deserialized;
}
All was working fine in Android in debug mode but in iOS both debug and release and in Android release mode. The deserialization code crashed with the following exceptions
Android -> Release
[MonoDroid] at MessagePa07-10 18:06:01.269 I/MonoDroid(13495): MessagePack.MessagePackSerializationException: Failed to deserialize Project.Core.Models.SomeData Class value. ---> System.TypeInitializationException: The type initializer for 'FormatterCache`1' threw an exception. ---> MessagePack.Internal.MessagePackDynamicObjectResolverException: can't find public constructor. type:System.Drawing.Drawing2D.Matrix
[MonoDroid] at MessagePack.Internal.ObjectSerializationInfo.CreateOrNull (System.Type type, System.Boolean forceStringKey, System.Boolean contractless, System.Boolean allowPrivate) [0x009a0] in <23c4c9b023514c20801c8f07fd69206c>:0
[MonoDroid] at MessagePack.Internal.DynamicObjectTypeBuilder.BuildType (MessagePack.Internal.DynamicAssembly assembly, System.Type type, System.Boolean forceStringKey, System.Boolean contractless) [0x00015] in <23c4c9b023514c20801c8f07fd69206c>:0
iOS->
System.TypeInitializationException: The type initializer for 'Project.Core.Helpers.BinarySerializer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.ContractlessStandardResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Internal.StandardResolverHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.DynamicEnumResolver' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x0001a] in <f04e2061de5c414991b8e36a20354820>:0
at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00010] in <f04e2061de5c414991b8e36a20354820>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at MessagePack.Internal.StandardResolverHelper..cctor () [0x00000] in <f04e2061de5c414991b8e36a20354820>:0
--- End of inner exception stack trace ---
Found the section in the MessagePack git page specifying a way to overcome this issue using an Ahead of time code generator. I followed the steps but was not able to fix the issue. Also I'm sure I'm doing it right.
How do I use MessagePack in Xamarin.Forms. Can anyone who has already suggest me or provide a reference.
Update on steps followed
Used message pack serialization in a button click.
Installed mpc tool.
Used don't mpc -i "{FormsProject.csproj path}" -o "{FormsProject directory path}"
Added the created message pack generated class to the forms project.
Used the following code in App.xaml.cs Initialize method
StaticCompositeResolver.Instance.Register(
MessagePack.Resolvers.GeneratedResolver.Instance,
MessagePack.Resolvers.StandardResolver.Instance
Now also the (Operation is not supported in the platform) Exception is thrown. I'm not quite getting what I'm doing wring here.
Update 2:
Exception in the MessagePackSerializerOptions
System.TypeInitializationException: The type initializer for 'MessagePackSerializerOptionsDefaultSettingsLazyInitializationHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.StandardResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Internal.StandardResolverHelper' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.DynamicEnumResolver' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs:129
at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x0001a] in <f04e2061de5c414991b8e36a20354820>:0
at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00010] in <f04e2061de5c414991b8e36a20354820>:0
Require to set StaticCompositeResolver.Instance as default.
You lacks following code.
var option = MessagePackSerializerOptions.Standard.WithResolver(StaticCompositeResolver.Instance);
MessagePackSerializer.DefaultOptions = option;
Upgrade to version of MessagePack 2.1.165 or higher.
This issue was fixed in Message pack in version 2.1.165. Regarding the lazy loading of DynamicAssembly.
Issue link
Sorry if the title may be misleading, but I have created a decoder in c#, but how do I use the function on (save.dat (the game save)) it needs to be loaded in a byte array.
Code for the decoder: https://del.dog/sorononami
Sorry I'm a starter in c#.
I have tried but I got this error:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'ConsoleApp8.Program' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ConsoleApp8.Program.PwDecLol(Byte[] lel) in C:\repos\ConsoleApp8\ConsoleApp8\Program.cs:line 180
at ConsoleApp8.Program..cctor() in C:\repos\ConsoleApp8\ConsoleApp8\Program.cs:line 183
--- End of inner exception stack trace ---
at ConsoleApp8.Program.Main() in C:\repos\ConsoleApp8\ConsoleApp8\Program.cs:line 15
Looks like I am not doing it correctly
I don't think it's anything wrong with your decoder. The error message suggests you have a parameter in the constructor to your program, which the runtime doesn't know how to resolve.
Try removing any parameters from the main entry point into your programs (except string[] args).
Alternatively, post the code from your program's entry point.
The following line of code is causing me an Exception
plug.Instance.AddDocuments(new Int32[] { val_pid }, val_ptype, val_doccat, val_subcat, val_doctype, val_notes, val_summary, SummaryAppendOptions.None, val_docStatus, new String[] { PDFFile })
And this is the exception detail.
System.Exception was caught
Message=Object reference not set to an instance of an object. - Error when trying to save document
Source=SimsBridge
StackTrace:
at SimsBridge.Bridge.AddDocuments(Int32[] personIds, Int32 PersonType, String docCatagory, Int32 subCatagory, String docType, String notes, String summary, SummaryAppendOptions summaryOptions, String documentStatusCode, String[] filePaths)
at ManagedScanDesktop.Form1.SimsScanComplete(String[] files) in C:\Working\ManagedScanDesktop 1.8\v1.8\ManagedScanDesktop\ManagedScanDesktop\Form1.cs:line 2619
InnerException:
I'm not looking for a solution to the actual exception.
My question is, does the stacktrace point to which part of the method doesn't have a reference set? Or is stacktrace just to trace to where the method is called?
The stack trace shows you the call stack when an exception is thrown. From what you've provided you can only deduce that an exception was thrown from AddDocuments. Any of the reference type parameters passed in could be null. The best way to pinpoint the problems is to set a breakpoint and than inspect the values.
Your stack trace means that either SimsBridge or SimsBridge.Bridge is null.
The message is telling you that somewhere in AddDocuments a null reference exception was thrown. It could be one of the parameters or a member.
The project has been working fine in 2003 but when opening it in 2008 we now get the below error. I've tried ripping all of the code out of the 'Accessory' result map and then it just goes onto the next result map and tells me the same error with that one. Any thoughts?
[ERROR]-- Accessing Accessory Datasource --
Error: Data connection configurations are invalid.
Descriptive: Net.Autodata.Accessories.Exceptions.AccessoryConnectException: Failed loading iBATIS.NET Default SQL MAP ---> IBatisNet.Common.Exceptions.ConfigurationException:
- The error occurred while loading SqlMap.
- initialize ResultMap
- The error occurred in .
- Check the Accessories.Accessory. ---> IBatisNet.Common.Exceptions.ConfigurationException: Could not configure ResultMap named "Accessories.Accessory", Cause: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at IBatisNet.Common.Utilities.Objects.ObjectFactory.CreateFactory(Type typeToCreate, Type[] types)
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.GetChildNode(ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.Initialize(ConfigurationScope configScope)
--- End of inner exception stack trace ---
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.Initialize(ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.Serializers.ResultMapDeSerializer.Deserialize(XmlNode node, ConfigurationScope configScope)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.BuildResultMap()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureSqlMap()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)
--- End of inner exception stack trace ---
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean isCallFromDao)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument document, Boolean useConfigFileWatcher)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String resource, ConfigureHandler configureDelegate)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(ConfigureHandler configureDelegate)
at IBatisNet.DataMapper.Mapper.InitMapper()
at IBatisNet.DataMapper.Mapper.Instance()
at Net.Autodata.Accessories.Processing.Editor.AccessoryEditor..ctor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor.Processing\AccessoryEditor.cs:line 94
--- End of inner exception stack trace ---
at Net.Autodata.Accessories.Processing.Editor.AccessoryEditor..ctor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor.Processing\AccessoryEditor.cs:line 98
at Net.Autodata.Accessories.Editor.AccessoryEditor.LoadEditor() in C:\Perforce\Clients\GM\Accessories\Editor\main\Editor\AccessoryEditor.cs:line 1028
Project was originally compiled with .Net v1.1 Upgraded IBatis DLL's to 2.0 and now it works fine.