Executionengineexception string conversion error illegal byte sequence encounted in the input

System.ExecutionEngineException #6529 Comments I try to run application but get this error System.ExecutionEngineException String conversion error: Illegal byte sequence encounted in the input. at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi(intptr) at Microsoft.Xna.Framework.Audio.Microphone.PopulateCaptureDevices () [0x00081] in :0 at Microsoft.Xna.Framework.Audio.OpenALSoundController..ctor () [0x0003b] in :0 at Microsoft.Xna.Framework.Audio.OpenALSoundController.get_GetInstance () [0x00007] in :0 at Microsoft.Xna.Framework.SdlGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x000d2] in :0 at Microsoft.Xna.Framework.GamePlatform.PlatformCreate […]

Содержание

  1. System.ExecutionEngineException #6529
  2. Comments
  3. System Stats
  4. What MonoGame platform are you using:
  5. Chinese characters cause «String conversion error: Illegal byte sequence encounted in the input.» #7117
  6. Comments
  7. Exception in AST.Declaration VisitClassTemplate #1165
  8. Comments
  9. Weird `ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input` on Windows about kspe HOT 1 OPEN
  10. Comments (1)
  11. Related Issues (20)
  12. Recommend Projects
  13. React
  14. Vue.js
  15. Typescript
  16. TensorFlow
  17. Django
  18. Laravel
  19. Recommend Topics
  20. javascript
  21. server
  22. Machine learning
  23. Visualization
  24. Recommend Org
  25. Facebook
  26. Microsoft
  27. WinForms applications crash when a specific text is pasted into any control that can accept text. #18923
  28. Comments
  29. Steps to Reproduce
  30. Current Behavior
  31. Expected Behavior
  32. On which platforms did you notice this
  33. Stacktrace

System.ExecutionEngineException #6529

I try to run application but get this error

System.ExecutionEngineException
String conversion error: Illegal byte sequence encounted in the input.
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi(intptr)
at Microsoft.Xna.Framework.Audio.Microphone.PopulateCaptureDevices () [0x00081] in :0
at Microsoft.Xna.Framework.Audio.OpenALSoundController..ctor () [0x0003b] in :0
at Microsoft.Xna.Framework.Audio.OpenALSoundController.get_GetInstance () [0x00007] in :0
at Microsoft.Xna.Framework.SdlGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x000d2] in :0
at Microsoft.Xna.Framework.GamePlatform.PlatformCreate (Microsoft.Xna.Framework.Game game) [0x00000] in :0
at Microsoft.Xna.Framework.Game..ctor () [0x001fb] in :0
at Terminal.Payment.UI.Game1..ctor () [0x00000] in /media/destructor/Documents/Projects/TestSistema/TestSistema/Game1.cs:19
at Terminal.Payment.UI.Program.Main () [0x00001] in /media/destructor/Documents/Projects/TestSistema/TestSistema/Program.cs:17

Working directory

System Stats

  • MonoGame 3.7 from Nuget
  • Debian 9
  • Mono 5.16
  • .Net Framework is 4.7.1

What MonoGame platform are you using:

The text was updated successfully, but these errors were encountered:

Источник

Chinese characters cause «String conversion error: Illegal byte sequence encounted in the input.» #7117

Hi I’m running a dot net application under windows with mono. I have created library in C program to load my dot net application, but i found a bug in g_utf8_to_utf16 function.When my program is placed in a path with a Chinese character,mono can not load assembly, and all Chinese characters in path become messy codes. It causes the program can’t work correctly. After referenced the source code, I found that this is the result of the error of the g_utf8_to_utf16 function, it converts English characters but does not convert Chinese characters, eg ‘汉’. it will throw «String conversion error: Illegal byte sequence encounted in the input».This made me quite upset,because my program will run on the Chinese version of the Windows,I really do not know how to do. I think mono should support Wide char(wchar_t),That will make it easier for people in more countries to use.

The text was updated successfully, but these errors were encountered:

Could you help us to reproduce the issue with the sample we can use?

This is my C program:

After debugging,I found where the problem was : mono_file_map_open

Is there any other solution to this problem?
Or are some of the parameters not set right?

@jaykrell are you familiar with this code?

Call stack would be nice.

Windows 8 bit strings are generally not utf8, but are being treated here as so.
That is likely the problem.

The right fix is that mono should use unichar2 or wchar_t (more) extensively and avoid converting to 8 bits, except at the Posix boundary. This is how Windows works and is not unreasonable for all software. wchar_t is widely supported, not just on Windows. It doubles or quadruples some memory use, but that is already largely happening anyway. We and much other software already traffic extensively in wchar or unichar2 on all platforms.

1 The obnoxious non-fix is to tell user to call MultiByteToWideChar(CP_ACP) and then WideCharToMultiByte(CP_UTF8) on all 8 bit input before passing it to mono.
He has done something likely invalid but only subtley so.

2 A practical and friendly fix is wherever monoapi has mono_foo(const char* presumed_utf8) also
provide mono_foo_w(const wchar_t*), implemented by converting to utf8 and calling mono_foo.
(Very long term, the layering could/should be reversed, but that is probably never.)

«w» is for «wide» — for any given string-taking function CreateFile, Windows actually has CreateFIleW that takes wchar_t and CreateFileA that takes an 8bit string, in code page that can vary per user and per thread but is rarely UTF8 (only recently did Windows allow UTF8 as the implicit codepage).
While this ugly to be sure, it is a widely used existing practise and does work.
So follow that on a small scale. To start, one function, mono_domain_assembly_open_w.

The user’s code would remain invalid and not working, but easy to fix.
He would change char to wchar_t and A to W, «str» to «wcs», and append «_w» at the mono boundary.

3 Another gross fix, and risky because it might not work, is to try to pass the string through unmodified, to fopen instead _wfopen. This is risky because it depends on carefully never assuming the encoding of user input, and assuming whatever we pass it to agrees (it would in this case). And we’d have to discern user input from our own utf8 data. If our data is always 7-bit clean, then it is viable.

I suggest 2. It is small. It can be done incrementally but will never be huge — a bunch of one liners. It doesn’t contradict 1 or 3, but is more practical than 1 and more helpful than 3.

Источник

Exception in AST.Declaration VisitClassTemplate #1165

Brief Description

I am trying to create a cs interface to my c++ project under linux. I am using CPPSharp.CLI.exe and am running the latest master build and latest clang + llvm. I also tried the last stable version 0.8.22 with exact matching llvm and clang refspecs and experienced the same issue:

Not able to convert the type CppSharp.Parser.AST.ClassTemplateSpecialization (CppSharp.Parser.AST.DeclarationContext::basic_istream) since the resulting type CppSharp.AST.Class (std::basic_istream) cannot be cast to AST.ClassTemplateSecialization.

At a later stage I now get an Exception, but that may be a different issue.

Generating C# bindings for Linux x64.
Parsing libraries.
Parsing code.
Parsed ‘/home/dave/workspace/mw_trunk/mwcutsim/mwVerifierInterface/mwMachSimVerifier.hpp’
couldnt convert type CppSharp.Parser.AST.ClassTemplateSpecialization (CppSharp.Parser.AST.DeclarationContext::basic_istream) since the type after visiting CppSharp.AST.Class (std::basic_istream) cannot be cast to AST.ClassTemplateSecialization
String conversion error: Illegal byte sequence encounted in the input. at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi(intptr)
at Std.BasicStringExtensions.CStr (Std.BasicString3[_CharT,_Traits,_Alloc] this) [0x00026] in /home/dave/workspace/CppSharp.git/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs:986
at CppSharp.Parser.AST.Declaration.get_DebugText () [0x0001e] in /home/dave/workspace/CppSharp.git/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs:4599
at CppSharp.DeclConverter.VisitDeclaration (CppSharp.Parser.AST.Declaration decl, CppSharp.AST.Declaration _decl) [0x000b1] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:954
at CppSharp.DeclConverter.VisitNamespace (CppSharp.Parser.AST.Namespace decl) [0x0000a] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:1090
at CppSharp.DeclVisitor1[TRet].Visit (CppSharp.Parser.AST.Declaration decl) [0x000b4] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:184
at CppSharp.DeclConverter.Visit (CppSharp.Parser.AST.Declaration decl) [0x0006b] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:854
at CppSharp.DeclConverter.VisitDeclContext (CppSharp.Parser.AST.DeclarationContext ctx, CppSharp.AST.DeclarationContext _ctx) [0x00013] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:991
at CppSharp.ASTConverter.Convert () [0x00086] in /home/dave/workspace/CppSharp.git/src/Parser/ASTConverter.cs:409
at CppSharp.ClangParser.ConvertASTContext (CppSharp.Parser.AST.ASTContext context) [0x00009] in /home/dave/workspace/CppSharp.git/src/Parser/Parser.cs:81
at CppSharp.Driver.ParseCode () [0x001ef] in /home/dave/workspace/CppSharp.git/src/Generator/Driver.cs:162
at CppSharp.ConsoleDriver.Run (CppSharp.ILibrary library) [0x00090] in /home/dave/workspace/CppSharp.git/src/Generator/Driver.cs:428
at CppSharp.Generator.Run () [0x0014f] in /home/dave/workspace/CppSharp.git/src/CLI/Generator.cs:259
at CppSharp.CLI.Main (System.String[] args) [0x00044] in /home/dave/workspace/CppSharp.git/src/CLI/CLI.cs:279

Unhandled Exception:
System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
at CppSharp.CLI.Main (System.String[] args) [0x00075] in /home/dave/workspace/CppSharp.git/src/CLI/CLI.cs:286
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
at CppSharp.CLI.Main (System.String[] args) [0x00075] in /home/dave/workspace/CppSharp.git/src/CLI/CLI.cs:286

OS: Windows / OS X / Linux (include version and/or distro)
Linux (Ubuntu 18.10)

Used headers
Used settings

Target: MSVC/GCC/Clang
Clang (but had a similar issue with Gcc)

Stack trace or incompilable generated code

I have modified the function to get some insights. Before doing so an exception was thrown because an invalid cast was happening. Now I omit that but show the message.

The text was updated successfully, but these errors were encountered:

Источник

Weird `ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input` on Windows about kspe HOT 1 OPEN

There’s very good chance that we may be dealing with an environmental problem (or, at least, trigger).

In order to use it, one need to unzip it somewhere and then:

/Workspaces/…. should be replaced by the pathname of your KSP’s rigs you wanna test (yeah, you can run it on more than one). If the pathname have spaces or similar weirdyties you need to use double quotes on the pathnames:

The output will be something similar to this:

Assemblies that eventually fail the check will have an Exception name instead of an Ok on the line.

You can (or should) redirect the output to a file, so you can attach it on a post here or send me by mail:

A file called results.txt will be created on the current directory with the output.

  • Ensure this is working fine on KSP 1.12.x HOT 1
  • The Sandboxed File System is borking on symlinks. Again. HOT 5
  • SUPPORT page for CriticalComponentsAbsent Fatal Error HOT 36
  • Implement a Installment check for (yet) more bordelines use cases
  • Replace the need of the Kernel32.dll for Win64 rigs HOT 4
  • Workaround for `UnauthorizedAccessException ` in ` System.IO.Directory.GetDirectories` HOT 3
  • «The type initializer for ‘KSPe.1O.Hierarchy’ threw an exception.» HOT 2
  • Bug on `ConfigNodeWithSteroids.from`
  • Help with code refactoring HOT 15
  • Missing class: The type Initializer for ‘KSPe.IO.Hierarchy 1’ threw an exception error HOT 9
  • problem regarding KSPIE (interstellar extended) compatibility after 2.4.6.3 update HOT 14
  • The type initializer for ‘KSPe.1O.Hierarchy’ threw an exception — newest KspE and Lisias module manager. HOT 50
  • Mono’s Process.Process is leaking File Handlers when using `using` HOT 2
  • Use `RealPath` on everything that calls `System.IO`
  • TweakScale stopped working in Proton HOT 19
  • Implement Localizing on the Install Checker HOT 1
  • Append `KSPUtil.ApplicationRootPath` on internal pathnames before using. HOT 4
  • Dont get screwed by `System.IO.Directory.GetCurrentDirecrtory()` again. HOT 10
  • Fix the Installchecker for correctly explaining where to install things

Recommend Projects

React

A declarative, efficient, and flexible JavaScript library for building user interfaces.

Vue.js

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Typescript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

TensorFlow

An Open Source Machine Learning Framework for Everyone

Django

The Web framework for perfectionists with deadlines.

Laravel

A PHP framework for web artisans

Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

javascript

JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

Some thing interesting about web. New door for the world.

server

A server is a program made to process requests and deliver data to clients.

Machine learning

Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

Visualization

Some thing interesting about visualization, use data art

Some thing interesting about game, make everyone happy.

Recommend Org

Facebook

We are working to build community through open source technology. NB: members must have two-factor auth.

Microsoft

Open source projects and samples from Microsoft.

Источник

WinForms applications crash when a specific text is pasted into any control that can accept text. #18923

I just wanted to paste a piece text from Wikipedia in a Winforms application.

A similar bug reported in the xamarin bug tracker but no progress with it since 2017: https://xamarin.github.io/bugzilla-archives/60/60819/bug.html

Steps to Reproduce

  1. Paste following text into any RichTextControl, Textbox or anything that accepts pasted text: «Benzo[a]pyrene is a polycyclic aromatic hydrocarbon and the result of incomplete combustion of organic matter at temperatures between 300 °C (572 °F) and 600 °C (1,112 °F). The ubiquitous compound can be found in coal tar, tobacco smoke and many foods, especially grilled meats. » in a Winforms application. It even crashes if you paste into a file open dialog.

Apparently the issue is with the ° mark.

Current Behavior

Expected Behavior

It doesn’t crash and is able to handle the conversion (even if that means including a � instead.)

On which platforms did you notice this

[ ] macOS
[ X ] Linux
[ ] Windows

Version Used:

Mono JIT compiler version 6.8.0.105 (tarball Tue Feb 4 21:20:20 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)

Stacktrace

The text was updated successfully, but these errors were encountered:

Источник

hello everyone, i have an issue right now. when i try to open the game i got this error message:

Error while instantiating a mod of type HarmonyMod.HarmonyMain: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.

at (wrapper managed-to-native) System.Reflection.Assembly.get_code_base(System.Reflection.Assembly,bool)

at System.Reflection.Assembly.GetCodeBase (System.Boolean escaped) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.get_CodeBase () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.AssemblyName.Create (System.Reflection.Assembly assembly, System.Boolean fillCodebase) [0x00010] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.RuntimeAssembly.GetName (System.Boolean copiedName) [0x0000e] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.GetName () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at HarmonyLib.PatchProcessor.VersionInfo (System.Version& currentVersion) [0x00016] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyLib.Harmony.VersionInfo (System.Version& currentVersion) [0x00000] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyMod.HarmonyMain..ctor (Verse.ModContentPack content) [0x00007] in <aba6ae7c28de45aa95721e8d887a49e4>:0

at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)

at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <567df3e0919241ba98db88bec4c6696f>:0

— End of inner exception stack trace —

at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00095] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at Verse.LoadedModManager.CreateModClasses () [0x00076] in <0ee2c524c4be441e9b7f8bfcb20aca6f>:0

Verse.Log:Error(String, Boolean)

Verse.LoadedModManager:CreateModClasses()

Verse.LoadedModManager:LoadAllActiveMods()

Verse.PlayDataLoader:DoPlayLoad()

Verse.PlayDataLoader:LoadAllPlayData(Boolean)

Verse.<>c:<Start>b__6_1()

Verse.LongEventHandler:RunEventFromAnotherThread(Action)

Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()

System.Threading.ThreadHelper:ThreadStart_Context(Object)

System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)

System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)

System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)

System.Threading.ThreadHelper:ThreadStart()

Error while instantiating a mod of type Multiplayer.Client.MultiplayerMod: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.

at (wrapper managed-to-native) System.Reflection.Assembly.get_code_base(System.Reflection.Assembly,bool)

at System.Reflection.Assembly.GetCodeBase (System.Boolean escaped) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.get_CodeBase () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.AssemblyName.Create (System.Reflection.Assembly assembly, System.Boolean fillCodebase) [0x00010] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.RuntimeAssembly.GetName (System.Boolean copiedName) [0x0000e] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.GetName () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at HarmonyLib.HarmonySharedState+<>c.<SharedStateAssembly>b__5_1 (System.Reflection.Assembly a) [0x00000] in <026284b8b4324a28a7825619702a3e16>:0

at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) [0x0003f] in <351e49e2a5bf4fd6beabb458ce2255f3>:0

at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <351e49e2a5bf4fd6beabb458ce2255f3>:0

at HarmonyLib.HarmonySharedState.SharedStateAssembly () [0x0002e] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyLib.HarmonySharedState.GetState () [0x00010] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyLib.HarmonySharedState.GetPatchInfo (System.Reflection.MethodBase method) [0x00000] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyLib.PatchProcessor.Patch () [0x0006d] in <026284b8b4324a28a7825619702a3e16>:0

at HarmonyLib.Harmony.Patch (System.Reflection.MethodBase original, HarmonyLib.HarmonyMethod prefix, HarmonyLib.HarmonyMethod postfix, HarmonyLib.HarmonyMethod transpiler, HarmonyLib.HarmonyMethod finalizer) [0x00028] in <026284b8b4324a28a7825619702a3e16>:0

at Multiplayer.Client.MultiplayerMod.EarlyPatches () [0x000ad] in <bdfbdf537d3c4aaaa013acf6962effc6>:0

at Multiplayer.Client.MultiplayerMod..ctor (Verse.ModContentPack pack) [0x0001e] in <bdfbdf537d3c4aaaa013acf6962effc6>:0

at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)

at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <567df3e0919241ba98db88bec4c6696f>:0

— End of inner exception stack trace —

at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00095] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at Verse.LoadedModManager.CreateModClasses () [0x00076] in <0ee2c524c4be441e9b7f8bfcb20aca6f>:0

Verse.Log:Error(String, Boolean)

Verse.LoadedModManager:CreateModClasses()

Verse.LoadedModManager:LoadAllActiveMods()

Verse.PlayDataLoader:DoPlayLoad()

Verse.PlayDataLoader:LoadAllPlayData(Boolean)

Verse.<>c:<Start>b__6_1()

Verse.LongEventHandler:RunEventFromAnotherThread(Action)

Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()

System.Threading.ThreadHelper:ThreadStart_Context(Object)

System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)

System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)

System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)

System.Threading.ThreadHelper:ThreadStart()

Error in static constructor of Multiplayer.API.MP: System.TypeInitializationException: The type initializer for ‘Multiplayer.API.MP’ threw an exception. —> System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.

at (wrapper managed-to-native) System.Reflection.Assembly.get_code_base(System.Reflection.Assembly,bool)

at System.Reflection.Assembly.GetCodeBase (System.Boolean escaped) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.get_CodeBase () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.AssemblyName.Create (System.Reflection.Assembly assembly, System.Boolean fillCodebase) [0x00010] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.RuntimeAssembly.GetName (System.Boolean copiedName) [0x0000e] in <567df3e0919241ba98db88bec4c6696f>:0

at System.Reflection.Assembly.GetName () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0

at Multiplayer.API.MP+<>c.<.cctor>b__3_1 (System.Reflection.Assembly a) [0x00000] in <8ba44dda26634b2fa24ca0e956ccb3d2>:0

at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) [0x0003f] in <351e49e2a5bf4fd6beabb458ce2255f3>:0

at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <351e49e2a5bf4fd6beabb458ce2255f3>:0

at Multiplayer.API.MP..cctor () [0x0001a] in <8ba44dda26634b2fa24ca0e956ccb3d2>:0

— End of inner exception stack trace —

at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)

at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <567df3e0919241ba98db88bec4c6696f>:0

at Verse.StaticConstructorOnStartupUtility.CallAll () [0x0001a] in <0ee2c524c4be441e9b7f8bfcb20aca6f>:0

Verse.Log:Error(String, Boolean)

Verse.StaticConstructorOnStartupUtility:CallAll()

Verse.<>c:<DoPlayLoad>b__4_2()

Verse.LongEventHandler:ExecuteToExecuteWhenFinished()

Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()

Verse.LongEventHandler:LongEventsUpdate(Boolean&)

Verse.Root:Update()

Verse.Root_Entry:Update()

Error in static constructor of Multiplayer.Client.Multiplayer: System.TypeInitializationException: The type initializer for ‘Multiplayer.Client.Multiplayer’ threw an exception. —> System.NullReferenceException: Object reference not set to an instance of an object

at Multiplayer.Client.Multiplayer.SetUsername () [0x00000] in <bdfbdf537d3c4aaaa013acf6962effc6>:0

at Multiplayer.Client.Multiplayer..cctor () [0x001d6] in <bdfbdf537d3c4aaaa013acf6962effc6>:0

— End of inner exception stack trace —

at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(intptr)

at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (System.RuntimeTypeHandle type) [0x0002a] in <567df3e0919241ba98db88bec4c6696f>:0

at Verse.StaticConstructorOnStartupUtility.CallAll () [0x0001a] in <0ee2c524c4be441e9b7f8bfcb20aca6f>:0

Verse.Log:Error(String, Boolean)

Verse.StaticConstructorOnStartupUtility:CallAll()

Verse.<>c:<DoPlayLoad>b__4_2()

Verse.LongEventHandler:ExecuteToExecuteWhenFinished()

Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()

Verse.LongEventHandler:LongEventsUpdate(Boolean&)

Verse.Root:Update()

Verse.Root_Entry:Update()

if you know what is the issue and how can i fix this pls help

Describe the bug
When I using BepinEx and Harmony to patch a method,it throw ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.

To Reproduce
Steps to reproduce the behavior:

  1. The original method and its signature and class
Unity.Resources.Load(string path,Type systemTypeInstance);
  1. The patch code
[HarmonyPatch(typeof(Resources), "Load", new Type[] {typeof(string),typeof(Type)})]
public class ResourcesPatch
{
    [HarmonyPrefix]
    public static bool FixMethod(string path,Type systemTypeInstance,ref Object __result)
    {
        Main.LogInfo($"LoadAsset:<{systemTypeInstance}>({path}");
        if (Main.Instance.resourcesManager.TryGetAsset(path, systemTypeInstance, out var asset))
        {
            __result = asset;
            return true;
        }
        return false;
    }
}
  1. The output of the Harmony debug log
[Error  : Unity Log] ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
Stack trace:
System.Reflection.Assembly.GetCodeBase (System.Boolean escaped) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
(wrapper dynamic-method) System.Reflection.Assembly.DMD<System.Reflection.Assembly::get_CodeBase>(System.Reflection.Assembly)
System.Reflection.AssemblyName.Create (System.Reflection.Assembly assembly, System.Boolean fillCodebase) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.RuntimeAssembly.GetName (System.Boolean copiedName) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.Assembly.GetName () (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
UnityExplorer.ReflectionUtility.AssemblyLoaded (System.Object sender, System.AssemblyLoadEventArgs args) (at <7882e8efd4414f4ba2006db80ff80442>:0)
System.AppDomain.DoAssemblyLoad (System.Reflection.Assembly assembly) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence, System.Boolean refonly) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.AppDomain.Load (System.Byte[] rawAssembly, System.Byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
(wrapper remoting-invoke-with-check) System.AppDomain.Load(byte[],byte[],System.Security.Policy.Evidence)
System.AppDomain.Load (System.Byte[] rawAssembly) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
(wrapper remoting-invoke-with-check) System.AppDomain.Load(byte[])
System.Reflection.Assembly.Load (System.Byte[] rawAssembly) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
MonoMod.Utils.ReflectionHelper.Load (System.IO.Stream stream) (at <5be58f3c80ca41c4960cf35eb47d4341>:0)
MonoMod.Utils.ReflectionHelper.Load (Mono.Cecil.ModuleDefinition module) (at <5be58f3c80ca41c4960cf35eb47d4341>:0)
HarmonyLib.DelegateTypeFactory.CreateDelegateType (System.Type returnType, System.Type[] argTypes, System.Nullable`1[T] convention) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.DelegateTypeFactory.CreateDelegateType (System.Type returnType, System.Type[] argTypes) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Public.Patching.NativeDetourMethodPatcher.Init () (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Public.Patching.NativeDetourMethodPatcher..ctor (System.Reflection.MethodBase original) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Public.Patching.NativeDetourMethodPatcher.TryResolve (System.Object sender, HarmonyLib.Public.Patching.PatchManager+PatcherResolverEventArgs args) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Public.Patching.PatchManager.GetMethodPatcher (System.Reflection.MethodBase methodBase) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.PatchClassProcessor.ProcessPatchJob (HarmonyLib.PatchJobs`1+Job[T] job) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
Rethrow as HarmonyException: Patching exception in method static UnityEngine.Object UnityEngine.Resources::Load(string path, Type systemTypeInstance)
HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.PatchClassProcessor.Patch () (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Harmony.PatchAll (System.Type type) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
HarmonyLib.Harmony.CreateAndPatchAll (System.Type type, System.String harmonyInstanceId) (at <7f26c0a74c5b43c2a5fc5efd29ec63d6>:0)
SkySwordKill.Next.Main.Init () (at <f14fa6b0138f468e98b757c6a7cef1a3>:0)
SkySwordKill.Next.Main.Awake () (at <f14fa6b0138f468e98b757c6a7cef1a3>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.Application:.cctor()

4.How to reproduce
After discover the problem,I was trying to rename the game directory name.
When plugin path is D:softsteamsteamappscommon觅长生64BepInExpluginsNext.dll,it throw the Exception.
When plguin path is D:softsteamsteamappscommonM64BepInExpluginsNext.dll,it work well.
The application path is D:softsteamsteamappscommon觅长生64觅长生.exe

Runtime environment:

  • OS: Windows 10, 64bit
  • .NET version: 4.7.2
  • HarmonyX version: 2.5.5
  • Name of game or host application: 觅长生

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

ngspice

  • Summary

  • Files

  • Reviews

  • Support

  • Tutorials

  • Discussion

  • Tickets ▾

    • Patches
    • Feature Requests
    • Support Requests
    • Bugs
  • Mailing Lists

  • News

  • Git ▾

    • ngspice
    • ngspice-manuals
    • ngspice-web

Menu


  • Create Topic


  • Stats Graph

Forums

  • ngspice-devel
    370

  • ngspice-users
    878

  • Open Discussion
    99

  • Help
    302

  • ngspice tips and examples
    48

Help

  • Formatting Help

Memory layout of structures returned by Sharedspice callback function SendData()


Created:

2021-12-20

Updated:

2021-12-29

  • gel-division

    I’m attempting to build an interface for ngspice.dll through a C# caller app. I’m currently attempting to read the data ngspice.dll sends back during a transient analysis through the callback function SendData().

    The pointer to the vecvaluesall struct that is sent by sharedspice is read correctly by the C# caller (correctly parsing veccount, vecindex and vecsa). However, I’m having some trouble with the vecvalues struct array that is returned in pointer form though the vecsa variable

    Firstly, I cannot get the char* name variable of vecvalues to parse correctly. I’m currently storing the char* object as a C# IntPtr, just storing the pointer in integer format. However, as soon as I attempt to access the text data at this unmanaged memory location through Marshal.PtrToStringAnsi() (ANSI format) or Marshal.PtrToStringUni()(Unicode format), I get errors such as ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input., or the returned string from the Marshalling function is a couple random characters.

    Furthermore, I’m uncertain whether I’m reading the values of creal, cimag, is_scale and is_complex of the vecvalues struct correctly, as creal and cimag seem to yield extremely high positive and negative values.

    I’d appreciate some help on the memory layout of the vecvalues structures that are returned. I’ve tried defining my structures in C# with normal, explicit (tried padding with both 4 and 8 bytes) and sequential layouts, however, none of these options seem to yield correct results.

    Is ngspice.dll compiled in such way that each variable of the structure vecvalues are memory aligned? Or are the variables packed (perhaps in the interest of saving memory space)? Where might I be going wrong with the parsing of char* name from unmanaged memory?

    Below is my structure definitions in C# (variables names are slightly different to ngspice manual):

    public struct vecValuesAll          //this definition works as intended
        {
            public int vecCount;
            public int vecIndex;
            public IntPtr vecArray;
        };
    
        [StructLayout(LayoutKind.Sequential)] public struct vecValue      //this doesn't seem to work correctly
        {
            public IntPtr vecNamePtr;
            public double cReal;
            public double cImag;
            public bool isScale;
            public bool isComplex;
        };
    
        [StructLayout(LayoutKind.Explicit)] public struct vecValue       //assigning explicit memory offsets like this (word size of 8) also doesn't seem to work correctly
        {
            [FieldOffset(0)] public IntPtr vecNamePtr;
            [FieldOffset(8)] public double cReal;
            [FieldOffset(16)] public double cImag;
            [FieldOffset(24)] public bool isScale;
            [FieldOffset(32)] public bool isComplex;
        };
    

    Any help is appreciated. Thank you.

  • Holger Vogt

    ngspice uses c null-terminated, utf8 encoded standard strings. There is no memory management beyond allocating (and de-allocating) the memory on the heap.

    How do you get from vecArray to vecValue ?

    Is IntPtr the right thing? There is some discussion in the web on integers in 64-systems may truncate a pointer. See https://forum.unity.com/threads/problem-marshaling-c-char-to-string.731822/

    The structs directly access the internal storage areas of ngspice. There is no special copying of data. So you have to take care that the data vectors in their plots are still available (no commands ‘destroy’ or ‘unlet’ given before evaluating the vectors pointed to, for example).

  • gel-division

    Thanks very much for your suggestions. Unfortunately, I’ve not been able to fix the issue. Let me answer your questions and describe what I’ve tried since.


    How do you get from vecArray to vecValue ?

    I’m getting the vecsa pointer of the vecvaluesall structure that is sent by callback SendData(), then incrementing through memory locations directly, using the code below.

    var size = Marshal.SizeOf(typeof(vecValue));                        //get unmanaged size, in bytes, of the structure type 'vecValue'
    vecValue[] mangagedArray = new vecValue[length];                    //define 'mangagedArray'
    
    for (int i = 0; i < length; i++)                                    //increment through vector array (length = vecValuesAll.vecCount)
    {
        IntPtr nextStructureMemBlock = IntPtr.Add(unmanagedArray, i * size);        //increments pointer memory location to position of next struct in array (by incrementing through memory by the size (in bytes) of 'vecValue' structure)
        mangagedArray[i] = Marshal.PtrToStructure<vecValue>(nextStructureMemBlock);        //converts the memory block to a structure and copies it to the managed array
    }
    

    I’m not 100% confident that this method is correct, so for my testing of the main string conversion issue, I’ve mainly tried accessing mangagedArray[0], which should hold the first vecValue object, directly following the pointer location sent by vecValuesAll.vecsa.


    Is IntPtr the right thing? There is some discussion in the web on integers in 64-systems may truncate a pointer. See https://forum.unity.com/threads/problem-marshaling-c-char-to-string.731822/

    I may be mistaken, but that thread seems to mention this truncation issue occurring on the C application side, and not the C# caller’s side? Some googling seems to show that IntPtr is either 32 or 64 bit depending on the system that is being run? So… I’m assuming this particular problem shouldn’t be the issue…?


    The structs directly access the internal storage areas of ngspice. There is no special copying of data. So you have to take care that the data vectors in their plots are still available (no commands ‘destroy’ or ‘unlet’ given before evaluating the vectors pointed to, for example).

    I assume this isn’t an issue if you directly run the conversion functions directly from inside the SendData() callback function (which is what I’m currently doing, at least for the purposes of testing)?


    Also, thanks for clarifying which type of string ngspice returns. I don’t think the two methods that I used, Marshal.PtrToStringAnsi() and Marshal.PtrToStringUni() supports UTF-8. So, I attempted the method below to convert the string:

    unsafe{
        int length = 0;
    
        for (byte* j = (byte*)vecValue.vecNamePtr; *j != 0; j++, length++);        //starting from the pointer location, increments through memory until null terminator is found, to determine length of string
    
        var clrString = Encoding.UTF8.GetString((byte*)vecValue.vecNamePtr, length);       //gets string using pointer
    }
    

    This method does not work, unfortunately, as it just produces a string with mostly gibberish (see my example below).


    A few other things of note: Each execution of my Unity app, when the netlist is entered, and transient analysis is run, the values of vecValue[0] changes between each execution. No difference in netlist, etc, but the parsed data of vecValue[0] differs between executions. I’m assuming this means I’m reading incorrect areas of unmanaged memory, which most likely means the marshalling of the structure vecValue from unmanaged memory is not happening correctly.

    And, here is an example of the parsed data of vecValue[0] from one such instance:

    name = @�R~�
    creal = 9.66914275052348E-312
    cimag = 9.66914275004918E-312
    is_scale = True
    is_complex = True
    

    As can be seen, the string conversion is clearly wrong, and I think the numbers are as well, since they seem way too small.

    Thanks Holger Vogt for your help so far, really appreciate it.

     

    Last edit: gel-division 2021-12-22

  • Holger Vogt

  • gel-division

    What about this:
    https://www.codeproject.com/Articles/32125/Unmanaged-Arrays-in-C-No-Problem

    Thanks for the link. I had a look, and I’m having trouble understanding whether it is really necessary to define and deal with unmanaged arrays inside my C# caller. Should I not instead attempt to parse the unmanaged memory into a managed array, so that I can access that data in a safer way? The tutorial at the link also lists one of the reasons for defining unmanaged arrays as being if bidirectional communication with unmanaged code is necessary. I don’t require this, I only need to read the data. Please do let me know if my line of thinking is incorrect.


    I decided to address the issue of the incorrect parsing of unmanaged memory by taking a look at the raw bytes of memory. I’ve done this with the following snippet, which is run every time SendData() is called by Ngspice.

    var arr = new byte[128];            //stores raw bytes from memory
    string rawByteString = "";          //stores bytes as string
    
    Marshal.Copy(vecValuesAll.vecArray, arr, 0, 128);      //copy bytes from memory (starting from location of pointer vecValuesAll.vecArray) into byte array
    
    for(int i = 0; i < 128; i++){                       //copy byte array to string to view in readable format
        rawByteString += arr[i].ToString();
        rawByteString += ", ";
    }
    
    Debug.Log(rawByteString);       //print to log
    

    I ran my C# caller repeatedly, each time, it sent the following commands to Ngspice:
    remcirc
    circbyline RC Circuit
    circbyline V1 n1 0 5V
    circbyline R1 n1 n2 1k
    circbyline C1 n2 0 100F ic=0
    circbyline .end
    tran 1ms 10ms

    Here are the results:

    Image

    Direct link: https://i.imgur.com/AScGRb5.png

    Leftmost column is the data at the pointer vecValuesAll.vecArray, with data moving towards the right showing the data in memory past the location of the pointer. Each row of data is a different execution of my C# caller. I’ve broken the bytes up into blocks of 8, the word size as I’m on a 64-bit system.

    I’ve colour coded what I understand should be the first three structures of the struct array. (5 blocks of 8 bytes, each block of 8 corresponding to one variable of the vecValue structure, allowing for structure padding)

    Correct me if I’m wrong, but the data looks flat out wrong. There is massive amounts of variability between each successive run of the application, when, theoretically, the only data that should be different is the char* name. I also can’t find the corresponding memory areas which represent the Boolean values of the structure, which should (as I understand it), simply be a single 1 or 0 on the leftmost column of a block of 8 bytes, allowing for padding.


    I’m starting to think it may be a lot simpler to write a small translation CLI program in C/C++ which provides an interfaces between Ngspice.dll and C#, converting all this vector data into simple stdout.

     

    Last edit: gel-division 2021-12-24

  • Giles Atkinson

    I do not know C#, but my guess is that the code lacks a pointer dereference step. Structure member vecsa is a pointer to an array of pointers to structures, as can be seen in this line from the example code:

    v2dat = vdata->vecsa[vecgetnumber]->creal;

    Three dereference steps are need to go from function argument to data value.

    Also, it seems very unlikely that the C compiler would allocate 8 bytes for a bool. ngspice’s own bool.h has:

    typedef int bool;

    • gel-division

      Structure member vecsa is a pointer to an array of pointers to structures

      Holy cow. I cannot thank you enough for this.

      All the hours I spent banging my head against the table… I was working under the assumption that vecsa is a pointer directly to the array of structures, not a pointer to an array of pointers, with each pointer in the array addressing a structure.

      I have finally got it working!

      Also, it seems very unlikely that the C compiler would allocate 8 bytes for a bool. ngspice’s own bool.h has:
      typedef int bool;

      I unfortunately think I lack the knowledge to find a good testing methodology for whether the booleans of the vecvalues structure are being parsed correctly. I don’t think I need these variables for my use case, so I’m not going to worry too much about these for the time being.

      For anyone stumbling across this thread in the future, as @h_vogt stated here that Ngspice currently doesn’t have any example code for interfacing sharedspice with C#, so I’ve put together a sample script of my work here, on GitHub. I’ll update the sample script to include this functionality for reading the structures returned by SendData().

      Once again, @gatk555, my sincerest thanks. I had actually given up on my direct C# interface and began putting together a C++ console app to handle communication with sharedspice, before I saw your response 😅

       

      Last edit: gel-division 2021-12-29

  • Giles Atkinson

    You are very welcome. I think congratulations are due for getting such a disparate set of software components to work together.

    Would it be rude to ask what you are building? My favourite guess is a game whose player must solve a series of electronic design and repair puzzles.


Log in to post a comment.

Понравилась статья? Поделить с друзьями:
  • Execution of this application has stopped due to a run time error
  • Execution error variable get
  • Execution error return code 2 from org apache hadoop hive ql exec mr mapredtask
  • Execution error return code 1 from org apache hadoop hive ql exec mr mapredlocaltask
  • Execution error pcre limits exceeded