Skip to main content

Posts

Showing posts with the label C#

Minimal OPC UA client that auto generates self signed certificate on startup in C#

Minimal OPC UA client that auto generates self signed certificate on startup in C# This is minimal OPC UA client in C# that demonstrates self signed certificate auto generation on startup. Pre-Req Visual Studio 2022 Community Edition ConsoleReferenceServer running in the another console Steps Using Visual Studio, create C# .Net 6.0 Application Add a nuget reference to OPCFoundation.NetStandard.Opc.Ua.Client Copy/paste code from gist below into Program.cs and run it Full working code can be found here .

OPC UA Read service using C#

OPC UA Read service using C# This is a sample bare bones OPC UA C# application performing a Read service. Pre-Req Visual Studio 2022 Community Edition Run sample ConsoleReferenceServer Steps Using Visual Studio, create C# .Net 6.0 Application Add a nuget reference to OPCFoundation.NetStandard.Opc.Ua.Client Copy/paste code from gist below into Program.cs Full working code can be found here .

C#: Convert SecureString to String

Sample code to convert C# SecureString to String. Note that this is not the most secure to access SecureString. Line 20 is one example of converting SecureString to String, this only works for .Net Framework 4.0 or later. Lines 23 to 38 converts SecureString to String and works using .Net Framework 2.0 or up. Reference(s): https://stackoverflow.com/questions/818704/how-to-convert-securestring-to-system-string </>

PInvoke.net alternative

http://pinvoke.net/ is my goto location when I need to call native functions into C#. I just found out today that there is actually an alternative from Microsoft called P/Invoke Interop Assistant, head to the link below to get the binaries. http://clrinterop.codeplex.com/ http://clrinterop.codeplex.com/releases/view/14120