Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple csharp with SHA256CryptoServiceProvider #92

Closed
pengzeshan opened this issue Sep 21, 2021 · 3 comments
Closed

Simple csharp with SHA256CryptoServiceProvider #92

pengzeshan opened this issue Sep 21, 2021 · 3 comments

Comments

@pengzeshan
Copy link

I have a simple csharp code related to SHA256CryptoServiceProvider. Here is a simple example csharp code:
using System;
using System.Security.Cryptography;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var ha = new SHA256CryptoServiceProvider();
Console.WriteLine("hello again");
}
}
}

Error message:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "Translate" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
at IL2C.Metadata.MethodInformation.get_IsConstructor() in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\Metadata\MethodInformation.cs:line 164
at IL2C.ILConverters.NewobjConverter.Prepare(IMethodInformation ctor, DecodeContext decodeContext) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\ILConveters\NewConverters.cs:line 77
at IL2C.ILConverters.ILConverter1.Prepare(Object operand, DecodeContext decodeContext) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\ILConveters\ILConverter.cs:line 61 at IL2C.AssemblyPreparer.<>c__DisplayClass3_2.<PrepareMethodBody>b__11(ILBody ilBody) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 138 at System.Linq.Enumerable.<>c__DisplayClass7_03.b__0(TSource x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__172.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable1.<GetEnumerator>d__1.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at IL2C.AssemblyPreparer.PrepareMethodBody(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 134
at IL2C.AssemblyPreparer.PrepareMethod(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 256
at IL2C.AssemblyPreparer.<>c__DisplayClass5_0.b__4(<>f__AnonymousType12 <>h__TransparentIdentifier0) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 310 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext, Func2 predictType, Func2 predictMethod) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 305
at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 320
at IL2C.SimpleDriver.Translate(TextWriter logw, CodeTextStorage storage, Boolean readSymbols, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String assemblyPath) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 39
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, IEnumerable`1 assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 121
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String[] assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 142
at IL2C.Translate.Execute() in D:\PROJECT\IL2C\IL2C.Tasks\Translate.cs:line 86
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() ConsoleApp1 C:\Users\damon.peng.nuget\packages\il2c.build\0.4.113\build\IL2C.Build.targets 19

Here is the IL2C.Build version used to trigger the above error:

@kekyo
Copy link
Owner

kekyo commented Oct 9, 2021

@pengzeshan Sorry delay, unfortunately SHA256CryptoServiceProvider implementation doesn't port into IL2C. I think if I port it:

  • Pure sha256 native code (by C lang) links into your app (with ld option).
  • Write bridge code fragment by IL2C/Invoke semanrics or P/Invoke's.
    • Caution: P/Invoke support is very experimental stage and lack a lot of features, so I recommend using IL2C/Invoke.

@kekyo
Copy link
Owner

kekyo commented Oct 9, 2021

If you want to get more IL2C/Invoke information, I recommend referring my blog entry Try writing code using both the Azure Sphere Development Kit and C#

  • IL2C already dropped Azure Sphere environment (Reason), but I think fill and understand this feature.
  • It's bit older, very poor English :)

@kekyo
Copy link
Owner

kekyo commented Oct 15, 2021

Related #91 , close this issue.

@kekyo kekyo closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants