Skip to content

Commit 1ac88d7

Browse files
committed
- switch to new project an solution format
- automatic load openSSL in the correct version (x86/x64)
1 parent ecd72f8 commit 1ac88d7

File tree

16 files changed

+204
-676
lines changed

16 files changed

+204
-676
lines changed

src/DriverTest/DriverTest.csproj

Lines changed: 34 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,35 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}</ProjectGuid>
8-
<OutputType>Exe</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>DriverTest</RootNamespace>
11-
<AssemblyName>DriverTest</AssemblyName>
12-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15-
<TargetFrameworkProfile />
16-
</PropertyGroup>
17-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
18-
<DebugSymbols>true</DebugSymbols>
19-
<OutputPath>bin\x64\Debug\</OutputPath>
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<DebugType>full</DebugType>
22-
<PlatformTarget>x64</PlatformTarget>
23-
<LangVersion>7.3</LangVersion>
24-
<ErrorReport>prompt</ErrorReport>
25-
<Prefer32Bit>true</Prefer32Bit>
26-
</PropertyGroup>
27-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
28-
<OutputPath>bin\x64\Release\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<Optimize>true</Optimize>
31-
<DebugType>pdbonly</DebugType>
32-
<PlatformTarget>x64</PlatformTarget>
33-
<LangVersion>7.3</LangVersion>
34-
<ErrorReport>prompt</ErrorReport>
35-
<Prefer32Bit>true</Prefer32Bit>
36-
</PropertyGroup>
37-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
38-
<DebugSymbols>true</DebugSymbols>
39-
<OutputPath>bin\x86\Debug\</OutputPath>
40-
<DefineConstants>DEBUG;TRACE</DefineConstants>
41-
<DebugType>full</DebugType>
42-
<PlatformTarget>x86</PlatformTarget>
43-
<LangVersion>7.3</LangVersion>
44-
<ErrorReport>prompt</ErrorReport>
45-
<Prefer32Bit>true</Prefer32Bit>
46-
</PropertyGroup>
47-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
48-
<OutputPath>bin\x86\Release\</OutputPath>
49-
<DefineConstants>TRACE</DefineConstants>
50-
<Optimize>true</Optimize>
51-
<DebugType>pdbonly</DebugType>
52-
<PlatformTarget>x86</PlatformTarget>
53-
<LangVersion>7.3</LangVersion>
54-
<ErrorReport>prompt</ErrorReport>
55-
<Prefer32Bit>true</Prefer32Bit>
56-
</PropertyGroup>
57-
<ItemGroup>
58-
<Reference Include="System" />
59-
<Reference Include="System.Core" />
60-
<Reference Include="System.Xml.Linq" />
61-
<Reference Include="System.Data.DataSetExtensions" />
62-
<Reference Include="Microsoft.CSharp" />
63-
<Reference Include="System.Data" />
64-
<Reference Include="System.Net.Http" />
65-
<Reference Include="System.Xml" />
66-
</ItemGroup>
67-
<ItemGroup>
68-
<Compile Include="Program.cs" />
69-
<Compile Include="Properties\AssemblyInfo.cs" />
70-
<Compile Include="TestPlcTag.cs" />
71-
</ItemGroup>
72-
<ItemGroup>
73-
<None Include="App.config" />
74-
</ItemGroup>
75-
<ItemGroup>
76-
<ProjectReference Include="..\S7CommPlusDriver\S7CommPlusDriver.csproj">
77-
<Project>{781951d8-80de-4e2f-92ca-a5fef0059415}</Project>
78-
<Name>S7CommPlusDriver</Name>
79-
</ProjectReference>
80-
</ItemGroup>
81-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82-
<PropertyGroup>
83-
<PostBuildEvent>xcopy /y /d "$(SolutionDir)S7CommPlusDriver\OpenSSL-dll-$(PlatformName)\*.dll" "$(ProjectDir)$(OutDir)"</PostBuildEvent>
84-
</PropertyGroup>
85-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
86-
Other similar extension points exist, see Microsoft.Common.targets.
87-
<Target Name="BeforeBuild">
88-
</Target>
89-
<Target Name="AfterBuild">
90-
</Target>
91-
-->
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
8+
<OutputPath>bin\x64\Debug\</OutputPath>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
11+
<OutputPath>bin\x64\Release\</OutputPath>
12+
</PropertyGroup>
13+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
14+
<OutputPath>bin\x86\Debug\</OutputPath>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
17+
<OutputPath>bin\x86\Release\</OutputPath>
18+
</PropertyGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\S7CommPlusDriver\S7CommPlusDriver.csproj" />
21+
</ItemGroup>
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
24+
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
25+
</ItemGroup>
26+
<PropertyGroup>
27+
<AssemblyTitle>DriverTest</AssemblyTitle>
28+
<Description>S7CommPlusDriver Test</Description>
29+
<Product>DriverTest</Product>
30+
<Copyright>Copyright © 2023, Thomas Wiens</Copyright>
31+
<AssemblyVersion>0.1.0.0</AssemblyVersion>
32+
<FileVersion>0.1.0.0</FileVersion>
33+
<PlatformTarget>x86</PlatformTarget>
34+
</PropertyGroup>
9235
</Project>

src/DriverTest/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Program
1414
{
1515
static void Main(string[] args)
1616
{
17-
string HostIp = "192.168.1.30";
17+
string HostIp = "10.0.98.100";
1818
string Password = "";
1919
int res;
2020
List<ItemAddress> readlist = new List<ItemAddress>();
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
4-
5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("DriverTest")]
9-
[assembly: AssemblyDescription("S7CommPlusDriver Test")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("DriverTest")]
13-
[assembly: AssemblyCopyright("Copyright © 2023, Thomas Wiens")]
144
[assembly: AssemblyTrademark("")]
155
[assembly: AssemblyCulture("")]
166

@@ -21,16 +11,3 @@
2111

2212
// The following GUID is for the ID of the typelib if this project is exposed to COM
2313
[assembly: Guid("94755b6a-7e0d-40f9-a2ed-48ff0c0fea2b")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.1.0.0")]
36-
[assembly: AssemblyFileVersion("0.1.0.0")]

src/S7CommPlusDriver.sln

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/S7CommPlusDriver.slnx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Solution>
2+
<Project Path="DriverTest\DriverTest.csproj" />
3+
<Project Path="S7CommPlusDriver\S7CommPlusDriver.csproj" />
4+
<Project Path="S7CommPlusGUIBrowser\S7CommPlusGUIBrowser.csproj" />
5+
<Project Path="Zlib.net\Zlib.net.csproj" />
6+
</Solution>
-4.91 MB
Binary file not shown.
-760 KB
Binary file not shown.

src/S7CommPlusDriver/OpenSSL/Native.cs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,38 @@
1414
#endregion
1515

1616
using System;
17+
using System.IO;
18+
using System.Reflection;
1719
using System.Runtime.InteropServices;
1820
using System.Text;
1921

2022
namespace OpenSsl
2123
{
22-
#if _WIN64
23-
using size_t = UInt64;
24-
#else
25-
using size_t = UInt32;
26-
#endif
24+
2725

2826
public class Native
29-
{
30-
#if _WIN64
31-
const string DLLNAME = "libcrypto-3-x64.dll";
32-
const string SSLDLLNAME = "libssl-3-x64.dll";
33-
#else
34-
const string DLLNAME = "libcrypto-3.dll";
35-
const string SSLDLLNAME = "libssl-3.dll";
36-
#endif
27+
{
28+
static Native()
29+
{
30+
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), DllImportResolver);
31+
}
32+
33+
private static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
34+
{
35+
if (libraryName == DLLNAME || libraryName == SSLDLLNAME)
36+
{
37+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
38+
{
39+
return NativeLibrary.Load(Path.Combine(RuntimeInformation.ProcessArchitecture.ToString().ToLower(), libraryName + ".dll"), assembly, searchPath);
40+
}
41+
}
42+
43+
// Otherwise, fallback to default import resolver.
44+
return IntPtr.Zero;
45+
}
46+
47+
const string DLLNAME = "libcrypto-3";
48+
const string SSLDLLNAME = "libssl-3";
3749

3850
#region Delegates
3951

@@ -269,7 +281,7 @@ public class Native
269281

270282
// size_t BIO_ctrl_pending(BIO *b);
271283
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
272-
public static extern size_t BIO_ctrl_pending(IntPtr bio);
284+
public static extern nint BIO_ctrl_pending(IntPtr bio);
273285

274286
// void BIO_free_all(BIO *a);
275287
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
@@ -321,7 +333,7 @@ public static long BIO_set_mem_eof_return(IntPtr b, int v)
321333
// void ERR_error_string_n(unsigned long e, char *buf, size_t len);
322334
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
323335
//public static extern void ERR_error_string_n(ulong e, IntPtr buf, size_t len);
324-
public static extern void ERR_error_string_n(ulong e, byte[] buf, size_t len);
336+
public static extern void ERR_error_string_n(ulong e, byte[] buf, nint len);
325337

326338
// unsigned long ERR_get_error(void);
327339
[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
4-
5-
// Allgemeine Informationen über eine Assembly werden über die folgenden
6-
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7-
// die einer Assembly zugeordnet sind.
8-
[assembly: AssemblyTitle("S7CommPlusDriver")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("S7CommPlusDriver")]
13-
[assembly: AssemblyCopyright("Copyright © 2023, Thomas Wiens")]
144
[assembly: AssemblyTrademark("")]
155
[assembly: AssemblyCulture("")]
166

@@ -21,16 +11,3 @@
2111

2212
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
2313
[assembly: Guid("781951d8-80de-4e2f-92ca-a5fef0059415")]
24-
25-
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26-
//
27-
// Hauptversion
28-
// Nebenversion
29-
// Buildnummer
30-
// Revision
31-
//
32-
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
33-
// indem Sie "*" wie unten gezeigt eingeben:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.1.0.0")]
36-
[assembly: AssemblyFileVersion("0.1.0.0")]

0 commit comments

Comments
 (0)