I have an application in MFC which creates shared memory using CreateFileMapping where I share a Struct object. In another console application in C++, I am accessing the shared memory using OpenFileMapping function and so the struct object is changed/accessed in both the applications.
Now, I want to redevelop my MFC Application in WPF C#. Is it possible to share the memory with the same console application as I have done earlier in MFC.
I have created one C# dll of .Net Framework 4.7.2. In this DLL, I want to deserialize the JSON file and when I have added the code for deserialization ,I got compilation error to install the NuGet package
After installing System.Text.Json NuGet package of latest version(5.0.2), dll builds successfully.
When I connect this Dll with the C++ application and calls the deserialization method of the DLL, at that time I got one run time exception stating that:
“Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.”
Solutions I Tried:
1) I tried to change in the app.config file with the value of the version which is specified in the error.
After changing in app. Config file , I got different run time exception:
“System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Buffers, Version=126.96.36.199, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'”
I tried changing the version of System. Buffers also in config file, but still getting the same error.
2) I tried to install the System.Text.Json of version 4.7.2
In this version also I am getting the same System. Buffers error.
Note: If we use the .Net 5.0.0(Core version) then System.Text.Json already present in it as default but with this version we are not able the generate the .tlb file as Regasm.exe gives error while registering the dll and in .Net 5.0.0 Register for COM interop is also disabled.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
I'm new to C# and coding in general. I've done some reading and online "hands-on" tutorials but I'm truly stuck here. Can someone please help me out and review the code I have written? I'm willing to put the time in to learn, I just don't know where to go from here.
I'm having a problem with my switch statement that involves different levels of commission rates, as well as getting the calculation to work. Also, on my last line it is giving me an error -- saying that "dblCalculateCommission"is an unassigned variable. I haven't had this problem on similar exercises. Appreciate any help, ready to pull my hair out!
private void btnCalculateCommission_Click(object sender, EventArgs e)
// declare variables to be used in the calculation
// convert the values in the text boxes to numeric and place into variables
dblSalesPersonLevel = Convert.ToDouble(txtSalesPersonLevel.Text);
dblAmountSold = Convert.ToDouble(txtAmountSold.Text);
// check the sales level is between 1 and 4, if it is outside of these parameters display an error message
if (dblSalesPersonLevel < 1)
MessageBox.Show("Sales level cannot be less than 1", "Input Error");
else if (dblSalesPersonLevel > 4)
MessageBox.Show("Sales level cannot be greater that 4", "Input Error");
// Calculate commissions based on sales person level
strSalesPersonLevel = txtSalesPersonLevel.Text;
dblCalculateCommission = 500 + (dblAmountSold * 0.02);
dblCalculateCommission = 750 + (dblAmountSold * 0.03);
dblCalculateCommission = 1000 + (dblAmountSold * 0.04);
dblCalculateCommission = 1250 + (dblAmountSold * 0.05);
// Convert commission into a string and place into a label with currency
lblCalculateCommission.Text = dblCalculateCommission.ToString("C2");
Last Visit: 31-Dec-99 18:00 Last Update: 26-Sep-21 12:24