c# How do I use this function on a file - c#

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.

Related

Why doesn't :cd command work in ScriptCS shell? (error CS1525)

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!

ArduinoUploader NuGet package

I have downloaded the NuGet package Arduino Uploader (https://www.nuget.org/packages/ArduinoUploader/), and receive the following error when trying to run it using the example on the github page (https://github.com/twinearthsoftware/ArduinoSketchUploader) under the .Net package.
The code is as follows
var upload = new ArduinoSketchUploader(
new ArduinoSketchUploaderOptions()
{
FileName = #"location of the file",
PortName = "COM7",
ArduinoModel = ArduinoModel.Micro
});
upload.UploadSketch();
The error of Exception unhandled occurs on the upload.UploadSketch(); line giving off
ArduinoUploader.ArduinoUploaderException: 'Exception during close of the programmer: 'Object reference not set to an instance of an object.'.'`.
The details copied from Visual Studio are `ArduinoUploader.ArduinoUploaderException
HResult=0x80131500
Message=Exception during close of the programmer: 'Object reference not set to an instance of an object.'.
Source=ArduinoUploader
StackTrace:
at ArduinoUploader.BootloaderProgrammers.Protocols.AVR109.Avr109BootloaderProgrammer.Close()
at ArduinoUploader.ArduinoSketchUploader.UploadSketch(IEnumerable`1 hexFileContents)
at ArduinoUploader.ArduinoSketchUploader.UploadSketch()
at arduino_sending_code.Program.Main(String[] args) in C:\Users\User\source\repos\arduino sending code\arduino sending code\Program.cs:line 39
This exception was originally thrown at this call stack:
[External Code]
arduino_sending_code.Program.Main(string[]) in Program.cs
Are there any suggestions to overcome this error?
The error you recieved is due to a dodgy hex file. You need to find the hex file from temp folder on your computer where the computer places them. Thats the only file which works. Also later on you might face an issue with another error, make sure you have the right programmer on the arduino, the details are avilable under the bootloader column on the ArduinoUploader github page.

FileNotFoundException - no file missing

When entering a view for the first time, this exception is raised:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
First of all - why would it just happen the first time I enter that specific view? Even IF the issue was in the constructor (which it could not be), it would be called (and the exception thrown) every time I enter the view.
Second of all - how would I find the source of such an exception? It doesn't break into the debugger, and there are no resource files (like background images, app bar icons) missing.
Lastly - what (except directly referencing files in the code) would throw such an exception?
I would show you the code in question, but the file is a bit too big to post all of it.
UPDATE:
After debugging, I have noticed that the error happens after the constructor and OnNavigatedTo() and before Loaded(). There is a thread being launched in the OnNavigatedTo method, but I have tried to try-catch every single element of that part (and every internal part of it), and no error was found.
UPDATE 2:
After debugging some more, I found the error message:
File or assembly name 'System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=xxxxxxxxxxxxx', or one of its dependencies, was not found.
Also the stack trace:
at System.ThrowHelper.throwVersion37CompatException(ExceptionType newEType,
String newString, ExceptionType oldEType, String oldString)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Windows.Resx..ctor()
at System.Windows.Resx.GetLoader()
at System.Windows.Resx.GetStringHelper(String name)
at System.Windows.Resx.GetString(String name)
at System.Windows.Controls.Primitives.ToggleButton.ToString()
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj,
IntPtr unmanagedObjArgs, Int32 argsTypeIndex,
Int32 actualArgsTypeIndex, String eventName)
you can set break for the first chance exception visual studio, debug in to see the detail about the FileNotFound exception, which file is missing.
sometime, clr try to find some extension dll, which is normally too magic to us. for example, if you use XmlSerialize in your project, if you don't use sgen.exe to generate the dynamic xml serialize dll for your serializble type, CLR will generate one during runtime, but before this, clr will try to load the assemble, which will cause FileNotFoundException, but catched

Correctly using stacktrace to debug

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.

IBatis.net converting project from VS2003 to VS2008 crashes on load

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.

Categories