C# und X509Certificate2

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

lagraf
Posts: 530
Joined: Thu Jan 18, 2018 9:03 am
Location: A

C# und X509Certificate2

Post by lagraf »

Hallo,
ich habe mir von github eine C# Sample App geladen, die ich nach X# transportieren wollte. Die C# Sample App habe ich in der XIDE compiliert und erhalte den Fehler

error CS1070: The type name 'X509Certificate2' could not be found. This type has been forwarded to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Consider adding a reference to that assembly. 18,25 AbstractCashRegisterSmardCard.cs Cashregister.Smartcard.AbstractCashRegisterSmardCard:ReadCertificate

Lib und Namespace System.Security.Cryptography.X509Certificates sind eingebunden, laut www ist diese für X509Certificate2 notwendig.

Was könnte das Problem sein?

LG Franz
User avatar
wriedmann
Posts: 4079
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: C# und X509Certificate2

Post by wriedmann »

Hallo Franz,
System ist als Lib eingebunden?
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
lagraf
Posts: 530
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: C# und X509Certificate2

Post by lagraf »

Hallo Wolfgang,
habe ich nun eingebunden, damit bringt mir der Compiler fehlende type/namespace Meldungen: CngKey, ECDsaCng, etc.
Die sollten in System.Security.Cryptography enthalten sein, die lib finde ich aber nicht in der Property Liste.
LG
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: C# und X509Certificate2

Post by Chris »

Hi Franz,

See https://learn.microsoft.com/en-us/dotne ... mework-4.8, this type for example is included in System.Core.dll, so you need to add this in the references
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
lagraf
Posts: 530
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: C# und X509Certificate2

Post by lagraf »

Hi Chris,
thank you for this info, now XIDE shows 3 errors (hope these are the last):
- CS0246 type or namespace 'ICardReader' not found
- CS1061 PCSC.SCardContext does not contain a definition for 'ConnectReader'
- CS0246 type or namespace 'ReaderStatus' not found

Do you know what to do?

regards Franz
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: C# und X509Certificate2

Post by Chris »

Hi Franz,

You're probably missing some using statements. Can you please post a link to the original source code you found and use?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
lagraf
Posts: 530
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: C# und X509Certificate2

Post by lagraf »

Hi Chris,
https://github.com/A-Trust/RKSV/tree/ma ... 20Examples
a.sign RK CHIP / APDU Examples / csharp / SampleClient
Regards
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: C# und X509Certificate2

Post by Chris »

Hi Franz,

There are several .cs files in there, not sure which one you are using. Did you include all the using statements from the one you are using? Also have you added the references to the necessary dlls?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
lagraf
Posts: 530
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: C# und X509Certificate2

Post by lagraf »

Hi Chris,
attached you find my XIDE C# application
Regards
Attachments
CSharpSampleClient.zip
(17.98 KiB) Downloaded 85 times
User avatar
Chris
Posts: 5630
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: C# und X509Certificate2

Post by Chris »

Hi Franz,

I am not familiar with the dll structure of this product, but from what I see in their sample, they have two references to external dll files, one to PCSC.dll and another to PCSC.Iso7816.dll. Your contains only one references, to a different named dll, pcsc-sharp.dll.

I don't know if you did this because you needed different functionality, but when I added the same dlls as the original sample uses, then your code compiles with no errors.

I took the dlls drom this browsers, after unzipping the sample code, downloaded from git:

\RKSV-main\a.sign RK CHIP\APDU Examples\csharp\packages\PCSC.5.0.0\lib\net40\PCSC.dll
\RKSV-main\a.sign RK CHIP\APDU Examples\csharp\packages\PCSC.Iso7816.5.0.0\lib\net40\PCSC.Iso7816.dll

I also tried the net472 versions (instead of net40), and that worked fine, too.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply