Some updates to the COM lib to attempt to get it to work on .net 8. Unfinished, porting all Access functions over to vs instead

This commit is contained in:
2025-05-01 18:39:08 +01:00
parent 7465940d48
commit 8e7cd00b74
9 changed files with 147 additions and 59 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ClearOutputDirectory>True</ClearOutputDirectory>
</PropertyGroup>
</Project>

View File

@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ILRepack -->
<Target Name="ILRepacker" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\*.dll" />
<InputAssemblies Include="$(OutputPath)*.dll" />
<!--ILRepack started complaining it can't resolve CSVHelper when building the project, hence the line below-->
<!--It's a hack, and will need updating when CSVHelper is updated, but I can't figure it out-->
<!--InputAssemblies Include="C:\Users\Bobbie\.nuget\packages\csvhelper\33.0.1\lib\net8.0\CsvHelper.dll"/-->
</ItemGroup>
<ILRepack
@@ -14,6 +18,8 @@
OutputFile="$(TargetPath)"
Parallel="true"
TargetKind="Dll"
LibraryPath="$(OutputPath)" />
LibraryPath="$(OutputPath)"
/>
</Target>
</Project>
<!-- /ILRepack -->
</Project>

View File

@@ -0,0 +1,11 @@
To setup on new computer:
1. Add the app.local.config to the users ..\AppData\Local\bnhtrade\ folder (create the bnhtrade folder)
2. CLone bnhtrade solution from the repo
3. Build bnhtradeCOM project
4. Register the COM host for COM. With an elevated prompt, navigate to the build directory and run "regsvr32 bnhtradeCOM.comhost.dll"
5.

View File

@@ -4,8 +4,17 @@
<OutputType>Library</OutputType>
<AssemblyName>bnhtradeCOM</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--Added the line below to copy all dll from .nuget folder to build output folder-->
<!--CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies-->
</PropertyGroup>
<PropertyGroup>
<PropertyGroup>
<!--https://learn.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com#register-the-com-host-for-com-->
<EnableComHosting>true</EnableComHosting>
</PropertyGroup>
<ItemGroup>
<ComHostTypeLibrary Include="bnhtradeCOM.tlb" />
</ItemGroup>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -24,15 +33,11 @@
<ProjectReference Include="..\bnhtrade.Core\bnhtrade.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.31" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup />
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)_RegAsmInstall.bat" "$(TargetDir)"
copy "$(ProjectDir)_RegAsmRefresh.bat" "$(TargetDir)"
copy "$(ProjectDir)_RegAsmUninstall.bat" "$(TargetDir)"</PostBuildEvent>
<AssemblyTitle>bnhtrade COM Type Library</AssemblyTitle>
<Company>bnhtrade</Company>
<Product>bnhtradeCOMAsm</Product>
@@ -40,4 +45,7 @@ copy "$(ProjectDir)_RegAsmUninstall.bat" "$(TargetDir)"</PostBuildEvent>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(ProjectDir)_RegAsmInstall.bat&quot; &quot;$(TargetDir)&quot;&#xD;&#xA;copy &quot;$(ProjectDir)_RegAsmRefresh.bat&quot; &quot;$(TargetDir)&quot;&#xD;&#xA;copy &quot;$(ProjectDir)_RegAsmUninstall.bat&quot; &quot;$(TargetDir)&quot;" />
</Target>
</Project>

View File

@@ -12,7 +12,7 @@ namespace bnhtrade.Core.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@@ -5,6 +5,8 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<!--Added the line below to copy all dll from .nuget folder to build output folder-->
<!--CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies-->
</PropertyGroup>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@@ -30,28 +32,29 @@
<Folder Include="Test\Product\" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\packages\AWSSDK.SecurityToken.3.7.300.76\analyzers\dotnet\cs\AWSSDK.SecurityToken.CodeAnalysis.dll" />
<Analyzer Include="..\..\packages\AWSSDK.SecurityToken.3.7.300.76\analyzers\dotnet\cs\SharedAnalysisCode.dll" />
<Analyzer Include="..\..\packages\AWSSDK.SQS.3.7.300.75\analyzers\dotnet\cs\AWSSDK.SQS.CodeAnalysis.dll" />
<Analyzer Include="..\..\packages\AWSSDK.SQS.3.7.300.75\analyzers\dotnet\cs\SharedAnalysisCode.dll" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="3.7.303.15" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.300.76">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="AWSSDK.Core" Version="3.7.402.47" />
<PackageReference Include="CSharpAmazonSpAPI" Version="1.7.17" />
<PackageReference Include="CsvHelper" Version="31.0.4" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="112.1.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Data\Database\Product\UpdateAmazonFeeEstimate.cs" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@@ -64,8 +64,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.4" />
</ItemGroup>
<PropertyGroup>
<AssemblyTitle>bnhtrade Scheduled Tasks</AssemblyTitle>

View File

@@ -48,11 +48,14 @@
dateTimeOrderSearch = new DateTimePicker();
label1 = new Label();
textboxOrderSearch = new TextBox();
tabAccounts = new TabPage();
btnExchangeRate = new Button();
tabControl1.SuspendLayout();
Receiving.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
((System.ComponentModel.ISupportInitialize)bsReceivingLines).BeginInit();
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).BeginInit();
tabAccounts.SuspendLayout();
SuspendLayout();
//
// tabControl1
@@ -61,19 +64,22 @@
tabControl1.Controls.Add(tabPage1);
tabControl1.Controls.Add(tabPage2);
tabControl1.Controls.Add(Receiving);
tabControl1.Location = new Point(12, 12);
tabControl1.Controls.Add(tabAccounts);
tabControl1.Location = new Point(14, 16);
tabControl1.Margin = new Padding(3, 4, 3, 4);
tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0;
tabControl1.Size = new Size(1022, 533);
tabControl1.Size = new Size(1168, 711);
tabControl1.TabIndex = 0;
tabControl1.SelectedIndexChanged += tabControl1_SelectedIndexChanged;
//
// tabPage1
//
tabPage1.Location = new Point(4, 24);
tabPage1.Location = new Point(4, 29);
tabPage1.Margin = new Padding(3, 4, 3, 4);
tabPage1.Name = "tabPage1";
tabPage1.Padding = new Padding(3);
tabPage1.Size = new Size(1014, 505);
tabPage1.Padding = new Padding(3, 4, 3, 4);
tabPage1.Size = new Size(1160, 678);
tabPage1.TabIndex = 0;
tabPage1.Text = "Home";
tabPage1.UseVisualStyleBackColor = true;
@@ -81,10 +87,11 @@
// tabPage2
//
tabPage2.AccessibleName = "";
tabPage2.Location = new Point(4, 24);
tabPage2.Location = new Point(4, 29);
tabPage2.Margin = new Padding(3, 4, 3, 4);
tabPage2.Name = "tabPage2";
tabPage2.Padding = new Padding(3);
tabPage2.Size = new Size(1014, 505);
tabPage2.Padding = new Padding(3, 4, 3, 4);
tabPage2.Size = new Size(1160, 678);
tabPage2.TabIndex = 1;
tabPage2.Text = "FBA Shipments";
tabPage2.UseVisualStyleBackColor = true;
@@ -98,10 +105,11 @@
Receiving.Controls.Add(dateTimeOrderSearch);
Receiving.Controls.Add(label1);
Receiving.Controls.Add(textboxOrderSearch);
Receiving.Location = new Point(4, 24);
Receiving.Location = new Point(4, 29);
Receiving.Margin = new Padding(3, 4, 3, 4);
Receiving.Name = "Receiving";
Receiving.Padding = new Padding(3);
Receiving.Size = new Size(1014, 505);
Receiving.Padding = new Padding(3, 4, 3, 4);
Receiving.Size = new Size(1160, 678);
Receiving.TabIndex = 2;
Receiving.Text = "Receiving";
Receiving.UseVisualStyleBackColor = true;
@@ -111,10 +119,10 @@
//
labelDataGridCount.Anchor = AnchorStyles.Right;
labelDataGridCount.ImageAlign = ContentAlignment.MiddleRight;
labelDataGridCount.Location = new Point(857, 70);
labelDataGridCount.Location = new Point(979, 93);
labelDataGridCount.Name = "labelDataGridCount";
labelDataGridCount.RightToLeft = RightToLeft.Yes;
labelDataGridCount.Size = new Size(129, 21);
labelDataGridCount.Size = new Size(147, 28);
labelDataGridCount.TabIndex = 6;
labelDataGridCount.Text = "labelListCount";
labelDataGridCount.TextAlign = ContentAlignment.MiddleLeft;
@@ -126,11 +134,13 @@
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn });
dataGridView1.DataSource = bsReceivingLines;
dataGridView1.Location = new Point(31, 94);
dataGridView1.Location = new Point(35, 125);
dataGridView1.Margin = new Padding(3, 4, 3, 4);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(955, 396);
dataGridView1.Size = new Size(1091, 528);
dataGridView1.TabIndex = 5;
dataGridView1.DoubleClick += dataGridView1_DoubleClick;
//
@@ -138,18 +148,23 @@
//
purchaseNumberDataGridViewTextBoxColumn.DataPropertyName = "PurchaseNumber";
purchaseNumberDataGridViewTextBoxColumn.HeaderText = "PurchaseNumber";
purchaseNumberDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseNumberDataGridViewTextBoxColumn.Name = "purchaseNumberDataGridViewTextBoxColumn";
purchaseNumberDataGridViewTextBoxColumn.Width = 125;
//
// purchaseDateDataGridViewTextBoxColumn
//
purchaseDateDataGridViewTextBoxColumn.DataPropertyName = "PurchaseDate";
purchaseDateDataGridViewTextBoxColumn.HeaderText = "PurchaseDate";
purchaseDateDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseDateDataGridViewTextBoxColumn.Name = "purchaseDateDataGridViewTextBoxColumn";
purchaseDateDataGridViewTextBoxColumn.Width = 125;
//
// itemDescriptionDataGridViewTextBoxColumn
//
itemDescriptionDataGridViewTextBoxColumn.DataPropertyName = "ItemDescription";
itemDescriptionDataGridViewTextBoxColumn.HeaderText = "ItemDescription";
itemDescriptionDataGridViewTextBoxColumn.MinimumWidth = 6;
itemDescriptionDataGridViewTextBoxColumn.Name = "itemDescriptionDataGridViewTextBoxColumn";
itemDescriptionDataGridViewTextBoxColumn.Width = 500;
//
@@ -157,19 +172,25 @@
//
purchaseLineIdDataGridViewTextBoxColumn.DataPropertyName = "PurchaseLineId";
purchaseLineIdDataGridViewTextBoxColumn.HeaderText = "PurchaseLineId";
purchaseLineIdDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseLineIdDataGridViewTextBoxColumn.Name = "purchaseLineIdDataGridViewTextBoxColumn";
purchaseLineIdDataGridViewTextBoxColumn.Width = 125;
//
// lineStatusDataGridViewTextBoxColumn
//
lineStatusDataGridViewTextBoxColumn.DataPropertyName = "LineStatus";
lineStatusDataGridViewTextBoxColumn.HeaderText = "LineStatus";
lineStatusDataGridViewTextBoxColumn.MinimumWidth = 6;
lineStatusDataGridViewTextBoxColumn.Name = "lineStatusDataGridViewTextBoxColumn";
lineStatusDataGridViewTextBoxColumn.Width = 125;
//
// purchaseIdDataGridViewTextBoxColumn
//
purchaseIdDataGridViewTextBoxColumn.DataPropertyName = "PurchaseId";
purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId";
purchaseIdDataGridViewTextBoxColumn.MinimumWidth = 6;
purchaseIdDataGridViewTextBoxColumn.Name = "purchaseIdDataGridViewTextBoxColumn";
purchaseIdDataGridViewTextBoxColumn.Width = 125;
//
// bsReceivingLines
//
@@ -177,9 +198,10 @@
//
// buttonSearch
//
buttonSearch.Location = new Point(865, 37);
buttonSearch.Location = new Point(989, 49);
buttonSearch.Margin = new Padding(3, 4, 3, 4);
buttonSearch.Name = "buttonSearch";
buttonSearch.Size = new Size(109, 25);
buttonSearch.Size = new Size(125, 33);
buttonSearch.TabIndex = 4;
buttonSearch.Text = "Search";
buttonSearch.UseVisualStyleBackColor = true;
@@ -190,9 +212,10 @@
comboBox1.DataSource = purchaseLineStatusBindingSource;
comboBox1.DisplayMember = "PurchaseLineStatusName";
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(195, 39);
comboBox1.Location = new Point(223, 52);
comboBox1.Margin = new Padding(3, 4, 3, 4);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(189, 23);
comboBox1.Size = new Size(215, 28);
comboBox1.TabIndex = 3;
comboBox1.ValueMember = "PurchaseLineStatusId";
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
@@ -204,35 +227,58 @@
//
// dateTimeOrderSearch
//
dateTimeOrderSearch.Location = new Point(31, 39);
dateTimeOrderSearch.Location = new Point(35, 52);
dateTimeOrderSearch.Margin = new Padding(3, 4, 3, 4);
dateTimeOrderSearch.Name = "dateTimeOrderSearch";
dateTimeOrderSearch.Size = new Size(131, 23);
dateTimeOrderSearch.Size = new Size(149, 27);
dateTimeOrderSearch.TabIndex = 2;
dateTimeOrderSearch.ValueChanged += dateTimeOrderSearch_ValueChanged;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(31, 21);
label1.Location = new Point(35, 28);
label1.Name = "label1";
label1.Size = new Size(75, 15);
label1.Size = new Size(95, 20);
label1.TabIndex = 1;
label1.Text = "Order Search";
//
// textboxOrderSearch
//
textboxOrderSearch.Location = new Point(417, 39);
textboxOrderSearch.Location = new Point(477, 52);
textboxOrderSearch.Margin = new Padding(3, 4, 3, 4);
textboxOrderSearch.Name = "textboxOrderSearch";
textboxOrderSearch.Size = new Size(415, 23);
textboxOrderSearch.Size = new Size(474, 27);
textboxOrderSearch.TabIndex = 0;
textboxOrderSearch.KeyPress += textboxOrderSearch_KeyPress;
//
// tabAccounts
//
tabAccounts.Controls.Add(btnExchangeRate);
tabAccounts.Location = new Point(4, 29);
tabAccounts.Name = "tabAccounts";
tabAccounts.Padding = new Padding(3);
tabAccounts.Size = new Size(1160, 678);
tabAccounts.TabIndex = 3;
tabAccounts.Text = "Accounts";
tabAccounts.UseVisualStyleBackColor = true;
//
// btnExchangeRate
//
btnExchangeRate.Location = new Point(48, 50);
btnExchangeRate.Name = "btnExchangeRate";
btnExchangeRate.Size = new Size(237, 50);
btnExchangeRate.TabIndex = 0;
btnExchangeRate.Text = "Exchange rate input";
btnExchangeRate.UseVisualStyleBackColor = true;
//
// Home
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1046, 557);
ClientSize = new Size(1195, 743);
Controls.Add(tabControl1);
Margin = new Padding(3, 4, 3, 4);
Name = "Home";
Text = "Form1";
Load += Form1_Load;
@@ -242,6 +288,7 @@
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
((System.ComponentModel.ISupportInitialize)bsReceivingLines).EndInit();
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).EndInit();
tabAccounts.ResumeLayout(false);
ResumeLayout(false);
}
@@ -266,5 +313,7 @@
private DataGridViewTextBoxColumn lineStatusDataGridViewTextBoxColumn;
private DataGridViewTextBoxColumn purchaseIdDataGridViewTextBoxColumn;
private Label labelDataGridCount;
private TabPage tabAccounts;
private Button btnExchangeRate;
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
@@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
@@ -120,6 +120,12 @@
<metadata name="bsReceivingLines.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>250, 17</value>
</metadata>
<metadata name="bsReceivingLines.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>250, 17</value>
</metadata>
<metadata name="purchaseLineStatusBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="purchaseLineStatusBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>