error well compling MemoryMappedFiles in FMB complier.
hey all. i'm been working on a script and i've run into an error... i assume its kinda bug? as unless i'm wrong i thought il-2 codbliz did uses atlest .net 4? which was when i`m told the fonctionnalité was added.
i'm very new to c# as im a c++ programmer, and untill this all my work was linux based, envroments and c++.. so forgive me if i've miss understood. however, i do get an "error" that being
" error CS0234: The type or namespace name 'MemoryMappedFiles' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)"
well trying to compile the script in the FMB. this is by useing the line "using System.IO.MemoryMappedFiles;` in said script.
the only things i can find online are saying that it would be due to outdated .net or that the `System.Core.dll assembly.`is not refrenced.. in the `complier`that is being used by il-2 blitz.. if i understand the flow of c#..
apologies if this is the wrong place. but if anyone does know.. what steps could be taken or if theirs a speific reson why this functionality been left out! perhaps be good tooo add in later? lol
Re: error well compling MemoryMappedFiles in FMB complier.
Please post a code sample that shows the problem.
Why are you using MemoryMappedFiles?
Re: error well compling MemoryMappedFiles in FMB complier.
That's what I was wondering.
IPC would be my first guess.
Re: error well compling MemoryMappedFiles in FMB complier.
if I remember correctly, you have to use something like
Code:
//include System.IO.MemoryMappedFiles
Hopefully someone that remembers the exact syntax can chime in.
Re: error well compling MemoryMappedFiles in FMB complier.
hey all thanks for the quick responce here ill give more details!
yup IPC i'm writing a c++ program that collects info from the c# scripts polling the engine. and then produces files and like displayed stuff etc. and then generates mis files that are then dynamically loaded. back in. I want to make it sound like a weird economic aspect into a dynamic campaign and alike server side ability to command units in, and like display a delayed “warmap” like in the control rooms of the real warrooms of the time.. etc. perhaps more wargame(the film) style but same idea... . and i know my c++ better and also its faster to have it doing simulations on a separate process. And i don't want to slow down the il-2 engine with unnecessary scripting in c# and rather have an independent process which is optimized and using its own memory, processor cycles etc.
As for my code. It never gets past the
Code:
using System.IO.MemoryMappedFiles;
is what i tried... the error
Code:
"error CS0234: The type or namespace name 'MemoryMappedFiles' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)
" and goes no further.
The rest is just really basic debug tests like right out of the windows documentation.. Not that it matters as the compiler won't find that memorymappedfile assembly thus “MemoryMappedFile” and all its functions are not found.
try a workaround loading in System.Core.dll into an assembly and then trying to create references to the functions. Via MethodInfo And then Invoke but that horror does not work,... as for the code itself its currently just testing the memmapfunction inside..
Code that uses that stuff..
Code:
//-$debug
//$reference parts\core\gamePlay.dll
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System;
using System.IO;
using System.IO.MemoryMappedFiles; //THIS IS WHAT THROWS ERROR! and is what supposed to be used.. i think?
using System.Reflection;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;
public class Mission : AMission
{
...{lots otherstuff not relvent..}
...
public override void OnBattleStarted() {
...
File.AppendAllText(LOG_FILE, "debug::data:::headsize::"+ header_base_size+ " charsize::" + char_size + "\r\n");
List<string> sample_stringlist = new List<string>(new string[]{"somestring", "anotherone", "this is number2222", "403"});
long offset = 0x00000000;
long acess_length = 0x00100000;
int header_base_size = Marshal.SizeOf(typeof(header_base));
int char_size =sizeof(char);
using (var mmf = MemoryMappedFile.CreateFromFile(CLODO_FILE_PATH+@"missions\Multi\costumz\script_update_notice.dat", FileMode.Open,"update_notice"))
{
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
long current_total =header_base_size;
long write_loc =header_base_size;
int i;
header_base read_head = new header_base();
accessor.Read(0, out read_head);
for(i =3; i <sample_stringlist.Count+3; i++)
{
string temp = sample_stringlist[i];
current_total += temp.Length*char_size;
if (current_total > acess_length)
{
File.AppendAllText(LOG_FILE, "###ERRROR::reached max virtual_shardfile.length..aborting write"+"\r\n");
break;
}
else
{
File.AppendAllText(LOG_FILE, "debug::forloop invoke"+ "\r\n");
accessor.Write(write_loc, ref temp );
write_loc = current_total;
}
}
File.AppendAllText(LOG_FILE, "debug::exitfoor"+ "\r\n");
read_head.line_num_data = i;
read_head.line_num_data -=3;
DateTime thisDay = DateTime.Today;
string c_date = thisDay.ToString("yyyyMMdd");
read_head.date_data = int.Parse(c_date);
accessor.Write(0, ref read_head);
}}
etc.
i then have other triggers and functions that track building destruction and where, and then will modfie the output from cities based on their destruction rigth now i just write it to file but to many diskwrites!
Code:
public override void OnBuildingKilled(string title, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
{
write stuff.
{
etc i could post the "failed" workaround method i tried. if anyones really into deep c# like layers. but it seems to be a huuge brutal means for what appears to be just a missing the "refrence" on the complier engine/build side. my guess is the System.Core.dll being pointed do is not the proper one.. and the engine is just poiting to an old pre net4 verson? its abit opaque cuz i cant see how the complier works. atlest not at the level im at...
microsoft docs::
MemoryMappedFile Class
Definition
Namespace:
System.IO.MemoryMappedFiles
Assembly:
System.IO.MemoryMappedFiles.dll
according to a stackoverflow
"MemoryMappedFile class belongs on System.IO.MemoryMappedFiles namespace and it is in System.Core.dll assembly."
https://stackoverflow.com/questions/...amespace-error
Re: error well compling MemoryMappedFiles in FMB complier.
add this line to the top and try again:
Code:
//$reference System.IO.MemoryMappedFiles.dll
Re: error well compling MemoryMappedFiles in FMB complier.
That seems like a complicated way to send data to an external process. Why not open a socket and write ASCII strings when events happen.
Re: error well compling MemoryMappedFiles in FMB complier.
It's so nice, from time to time, seeing people writing in Aramaic... :)
Re: error well compling MemoryMappedFiles in FMB complier.
Quote:
Originally Posted by
Erpr.Gr.210_Belial
It's so nice, from time to time, seeing people writing in Aramaic... :)
That's due to the faith developers have in miracles... :)
Re: error well compling MemoryMappedFiles in FMB complier.
hello, all sorry for a delayz time.we had a doomy heatwave here in québekystain and my home office has no outdoor windows... and then got caught up in database experiments. nevertheless.
the solution to my original problem appear to have be this
Code:
//$reference System.Core.dll
Thankz too ATAG_Colander for pointing me in the right direction seems this is they key i was looking for..
And I assume preparser command I was looking for!
The
Code:
//$reference System.IO.MemoryMappedFiles.dll
got me close. but it did give me an idea (it actually gave a different error
Code:
error CS1070: The type name 'MemoryMappedFile' could not be found. This type has been forwarded to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Consider adding a reference to that assembly.
the docs on microsoft stuff is weak.. always assuming you use Visual Studio lol which im not
anywho. i'm deep in other errors but at least solved this thanks all. i'll likely move future posts on this project to the more appropriate modding section... as my tests proved that directly depositing data from the il-2 engine into a SQLite database is performance heavy and also, prone to locking up the engine. thus think all my database stuff will be handled by the c++ program after the il-2 engine just writes data to the shared memory..
And it is possible using “socket and write ASCII strings” is definitely a possibility... iz just that i’ve been interested in shared memory mapping for a while and it perhaps is more of an experiment to make it work and learn how to do it. Even if its overkill in this situation.. Though i’d be interested to see final performance situations.. I suppose for me, i'm more comfortable with the notion of it being very much like files, just in memory(my studies were more on OS and concurrency work when i studied programing academically and less so in networking aspect), and as I don't mind dealing with concurrency issues and atomics. And I plan to design it in a way which should avoid deadlock or racecontions.. So for a little extra design work, feel the outcome be more rewarding..
Also found this neat wrapper i wanted to play with.
https://github.com/carlomilanesi/cpp-mmf soo on the c++ side defy interested to see how my interactions work out...
Anywhoz thanks all for the help!
Seems latest original issue is resolved for now! Haha.i;ll see if i can break something else now! ;)